<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0,viewport-fit=cover" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../../css/vant.css">
    <link rel="stylesheet" type="text/css" href="../../css/base.css" />
    <link rel="stylesheet" type="text/css" href="../../css/local.css" />
    <link rel="stylesheet" type="text/css" href="../../font/iconfont.css" />
    <link rel="stylesheet" href="../../script/elementui/lib/theme-chalk/index.css?t=1">
    <link href="../../script/elementui/vue-element-table.css" rel="stylesheet" />
    <script type="text/javascript" src="../../script/jquery.js"></script>
    <script type="text/javascript" src="../../script/layer/layer.js"></script>
    <script type="text/javascript" src="../../script/vue.min.js"></script>
    <script type="text/javascript" src="../../script/vant.min.js"></script>
    <script type="text/javascript" src="../../script/fastclick.js"></script>
    <script src="../../script/elementui/lib/index.js?t=1"></script>
    <script src="../../script/elementui/vue-element-bigdata-table.min.js?t=4"></script>
    <script type="text/javascript" src="../../script/base.js"></script>
    <script type="text/javascript" src="../../script/JSLINQ.js"></script>
    <script type="text/javascript" src="../../script/ajaxFileUpload.js"></script>
</head>
<style>
    body {
        zoom: 0.9;
    }

    .mainForm {
        height: 40%;
        overflow-y: auto;
    }

    .subFrame {
        height: 60%;
    }

    .van-tab {
        flex: inherit !important;
        width: 100px;
    }

    .van-tabs__nav {
        display: inline-flex !important;
        margin: 0px 0px !important;
    }

    .el-table--scrollable-y .el-table__body-wrapper {
        overflow-y: auto;
    }

    .part {
        margin-top: 0px;
        padding: 0px 5px 30px 5px;
        overflow: scroll;
    }

    .part .pf {
        border-radius: 6px;
        box-shadow: 0px 1px 5px rgb(200, 198, 198);
        background-color: #fff;
        overflow: hidden;
        position: relative;
    }

    .van-badge {
        margin: 10px 10px;
        background-color: #1989fa;
        color: #fff;
        display: block;
        width: 22px;
        padding: 3px;
        float: left;
        vertical-align: middle;
    }

    .upa {
        display: inline-block;
        vertical-align: bottom;
    }

    .van-cell {
        padding: 5px 16px !important;
    }
</style>

<body>
    <div id="app" v-cloak>
        <div class="box">
            <van-nav-bar-main :title="titleName" left-arrow @click-left="onClickLeft">
                <div slot="right">
                    <span slot="right" @click="openScan" v-if="!isPDA">
                        <img src="../../image/scan.png" />
                    </span>
                    <span slot="right" @click="openPrint" v-if="isPDA && printConfig">
                        <img src="../../image/print.png" />
                    </span>
                </div>
            </van-nav-bar-main>
            <div class="mainForm">
                <van-form>
                    <div v-for="(row,index) in formDesign">
                        <van-field v-if="row.baseProperty.controlType == 'datepicker'"
                            v-model="formData[row.baseProperty.controlName]" :name="row.baseProperty.controlName"
                            :label="row.baseProperty.labelName" :controlNo="row.baseProperty.controlNo" readonly="true"
                            :formatter="formatterDate" @click="clickDatePicker(row)"></van-field>
                        <van-field
                            v-else-if="row.baseProperty.controlType=='select' && row.controlProperty.select.type == 1"
                            v-model="formData[row.baseProperty.controlName+'_show']" is-link
                            :name="row.baseProperty.controlName" :label="row.baseProperty.labelName"
                            :controlNo="row.baseProperty.controlNo" readonly="true" @click="clickSelectPicker(row)">
                        </van-field>
                        <van-field
                            v-else-if="row.baseProperty.controlType=='select' && row.controlProperty.select.type == 3"
                            v-model="formData[row.baseProperty.controlName+'_show']" is-link
                            :name="row.baseProperty.controlName" :label="row.baseProperty.labelName"
                            :controlNo="row.baseProperty.controlNo" readonly="true"
                            @click="clickSelectWindowPicker(row)"></van-field>
                        <van-field v-else-if="row.baseProperty.controlType == 'number'"
                            v-model="formData[row.baseProperty.controlName]" :name="row.baseProperty.controlName"
                            :label="row.baseProperty.labelName" :controlNo="row.baseProperty.controlNo"
                            :readonly="row.baseProperty.isReadOnly" type="number" @change="dataChange(row)"></van-field>
                        <van-field v-else-if="row.baseProperty.controlType == 'textarea'"
                            v-model="formData[row.baseProperty.controlName]" :name="row.baseProperty.controlName"
                            :label="row.baseProperty.labelName" :controlNo="row.baseProperty.controlNo"
                            :readonly="row.baseProperty.isReadOnly" type="textarea" @change="dataChange(row)">
                        </van-field>
                        <van-field v-else-if="row.baseProperty.controlType == 'textbox'"
                            v-model="formData[row.baseProperty.controlName]" :name="row.baseProperty.controlName"
                            :label="row.baseProperty.labelName" :controlNo="row.baseProperty.controlNo"
                            :readonly="row.baseProperty.isReadOnly" @change="dataChange(row)"></van-field>
                        <van-col span="24" v-else-if="row.baseProperty.controlType == 'fileUpload'">
                            <van-cell>
                                <div class="row-title">{{ row.baseProperty.labelName }}</div>
                                <div class="row-content">
                                    <van-uploader v-model="formData[row.baseProperty.controlName+'_files']" multiple
                                        :before-delete="deleteUpload" :name="row.baseProperty.controlName"
                                        :show-upload="false"></van-uploader>
                                    <div class="upa">
                                        <div class="van-uploader__upload">
                                            <i class="van-icon van-icon-photograph van-uploader__upload-icon"></i>
                                            <input type="file" :name="row.baseProperty.controlName"
                                                :id="row.baseProperty.controlName" accept="image/*"
                                                @click="fileUploadClickPreview(row.baseProperty.controlName)"
                                                class="van-uploader__input" onchange="vm.uploadFile()">
                                        </div>
                                    </div>
                                </div>
                            </van-cell>
                        </van-col>
                    </div>

                </van-form>
            </div>
            <div class="subFrame">
                <van-tabs v-model="activeSubFrame" type="card" color="#83bff6" v-if="childFormList.length">
                    <van-tab v-for="childForm in childFormList" :title="childForm.title" :name="childForm.title">

                        <div style="width:100%;height:35px;" v-if="childForm.workList.length>0">
                            <van-button :icon="btn.icon" type="info" size="small" style="margin-right:5px;float:right"
                                v-for="btn in childForm.workList" @click="selfWorkHandler(childForm,btn)">{{ btn.name }}
                            </van-button>
                        </div>
                        <div v-if="childForm.showType=='table'">
                            <el-table :data="childForm.tableData" :height="childForm.tableHeight"
                                :width="childForm.tableWidth" @row-dblclick="childForm.dblClick">
                                <el-table-column width="50" :fixed="true" label="操作">
                                    <template slot-scope="scope">
                                        <van-icon name="delete-o" @click="delChildRow(childForm,scope.row)"
                                            color="#f00" />
                                    </template>
                                </el-table-column>
                                <el-table-column width="50" :fixed="true" label="序号">
                                    <template slot-scope="scope">
                                        {{scope.row['objNo']}}
                                    </template>
                                </el-table-column>
                                <el-table-column v-for="(col,index) in childForm.columns" v-if="!col.isHidden "
                                    :sortable="col.isOrder" :width="col.colWidth" :fixed="col.isFixed"
                                    :label="col.colDesc">
                                    <template slot-scope="scope">
                                        <span v-if="col.colType==2">
                                            {{ showActualValue(scope.row[col.colName],col) }}
                                        </span>
                                        <span v-else>
                                            {{scope.row[col.colName]}}
                                        </span>
                                    </template>
                                </el-table-column>
                            </el-table>
                        </div>

                        <div v-if="childForm.showType=='item'">
                            <div class="part" :style="{ height: childForm.tableHeight + 'px' }">
                                <van-list v-model="childForm.showListLoading" :finished="childForm.finished"
                                    finished-text="没有更多了" :immediate-check="false" @load="childForm.handleSizeChange">
                                    <div class="pf" v-for="item in childForm.tableData">
                                        <div class="pftitle">
                                            <el-checkbox v-model="item.checked"
                                                style="float:left;margin:10px 0px 0px 10px "
                                                v-if="isShowCheckBox(childForm.workList)"></el-checkbox>
                                            <div class="van-badge">{{ item.objNo }}</div>
                                            <van-icon name="delete-o" style="float:right;padding:10px 15px" color="#f00"
                                                @click="delChildRow(childForm,item)" />
                                        </div>
                                        <div v-for="(col,index) in childForm.columns">
                                            <van-field v-if="col.colType==1 && !col.isHidden"
                                                v-model="item[col.colName]" :name="col.colName" :label="col.colDesc"
                                                :readonly="col.isReadOnly" @change="itemDataChange(col,item,childForm)">
                                            </van-field>
                                            <van-field
                                                v-else-if="col.colType==2 && !col.isHidden && col.selDetail.type==1"
                                                :value="showActualValue(item[col.colName],col,item[col.colName+'_show'],item)"
                                                is-link :name="col.colName" :label="col.colDesc" readonly="true"
                                                @click="clickSelectPicker3(childForm,col,item)"></van-field>
                                            <van-field
                                                v-else-if="col.colType==2 && !col.isHidden && col.selDetail.type==3"
                                                :value="showActualValue(item[col.colName],col,item[col.colName+'_show'],item)"
                                                is-link :name="col.colName" :label="col.colDesc" readonly="true"
                                                @click="clickSelectWindowPicker3(childForm, col,item)">
                                                <template #button>
                                                    <van-button size="small" icon="scan" v-if="col.isScan"
                                                        @click="scanSelectWindowPicker3(childForm, col,item)">
                                                    </van-button>
                                                </template>
                                            </van-field>
                                            <van-field v-if="col.colType==3 && !col.isHidden"
                                                v-model="item[col.colName]" :name="col.colName" :label="col.colDesc"
                                                :readonly="col.isReadOnly" :formatter="formatterDate"
                                                @click="clickDatePicker3(col,item)"></van-field>
                                            <van-field v-if="col.colType==4 && !col.isHidden"
                                                v-model="item[col.colName]" :name="col.colName" :label="col.colDesc"
                                                :readonly="col.isReadOnly" type="number"
                                                @change="itemDataChange(col,item,childForm)"></van-field>
                                        </div>
                                        <!-- <van-field :label="col.colDesc" v-model="item[col.colName]" readonly v-for="col in childForm.columns" v-if="!col.isHidden"></van-field> -->
                                    </div>
                                </van-list>

                            </div>
                        </div>

                    </van-tab>
                    <!-- <van-tab title="明细2" name="2">明细2</van-tab> -->
                </van-tabs>
            </div>
            <div class="bottomSubmit"
                style="position: fixed;bottom: 0px;z-index: 1;width: 100%;padding: 5px 10px;right:0px">
                <div style="float:right;width:25%;">
                    <van-button round block type="info" native-type="submit" @click="saveRow"
                        v-if="!isUpdate && btn_showCondition(1,'新增')">提交</van-button>

                </div>
                <div style="float:right;width:25%;">
                    <van-button round block type="info" native-type="submit" @click="saveRow"
                        v-if="isUpdate && btn_showCondition(1,'编辑')">提交</van-button>
                </div>
                <div style="float:right;width:25%;" v-for="work in workList">
                    <van-button round block type="info" native-type="submit" v-if="btn_showCondition(2,work)"
                        @click="selfMainWorkHandler(work)">{{work.name}}</van-button>
                </div>
            </div>
        </div>

        <van-popup v-model="showDatePicker" position="bottom">
            <van-datetime-picker type="date" v-model="curDate" @confirm="onDatePickerConfirm"
                @cancel="onDatePickerCancel" />
        </van-popup>
        <van-popup v-model="showSelectPicker" position="bottom">
            <van-picker show-toolbar :columns="curSelectDataSource" :value-key="curSelect"
                @confirm="onSelectPickerConfirm" @cancel="onSelectPickerCancel" />
        </van-popup>
        <van-popup v-model="showDatePicker2" position="bottom">
            <van-datetime-picker type="date" v-model="curDate2" @confirm="onDatePickerConfirm2"
                @cancel="onDatePickerCancel2" />
        </van-popup>
        <van-popup v-model="showSelectPicker2" position="bottom">
            <van-picker show-toolbar :columns="curSelectDataSource2" :value-key="curSelect2"
                @confirm="onSelectPickerConfirm2" @cancel="onSelectPickerCancel2" />
        </van-popup>
        <van-popup v-model="showSelectPicker3" position="bottom">
            <van-picker show-toolbar :columns="curSelectDataSource3" :value-key="curSelect3"
                @confirm="onSelectPickerConfirm3" @cancel="onSelectPickerCancel3" />
        </van-popup>
        <van-popup v-model="showDatePicker3" position="bottom">
            <van-datetime-picker type="date" v-model="curDate3" @confirm="onDatePickerConfirm3"
                @cancel="onDatePickerCancel3" />
        </van-popup>
        <van-popup v-model="childEditPopup" position="bottom" :style="{ height: '40%' }">
            <div>
                <span style="color:#1989fa;font-size:14px;display:block;float:right;padding:10px"
                    @click="confirmEditPopup()">确定</span>
            </div>
            <van-form style="height:calc(100% - 20px);overflow:scroll;margin-top:40px">
                <div v-for="row in editFrame.columns">
                    <van-field v-if="row.colType == 1 && !row.isHidden" v-model="editValues[row.colName]"
                        :name="row.colName" :label="row.colDesc" :readonly="row.isReadOnly"
                        @change="tableDataChange(row)"></van-field>
                    <van-field v-else-if="row.colType == 2 && row.selDetail.type==1 && !row.isHidden"
                        v-model="editValues[row.colName+'_show']" :name="row.colName" :label="row.colDesc"
                        readonly="true" is-link @click="clickSelectPicker2(row)"></van-field>
                    <van-field v-else-if="row.colType == 2 && row.selDetail.type==3 && !row.isHidden"
                        v-model="editValues[row.colName+'_show']" is-link :name="row.colName" :label="row.colDesc"
                        readonly="true" @click="clickSelectWindowPicker2(row)"></van-field>
                    <van-field v-else-if="row.colType == 3 && !row.isHidden" v-model="editValues[row.colName]"
                        :name="row.colName" :label="row.colDesc" :readonly="row.isReadOnly" :formatter="formatterDate"
                        @click="clickDatePicker2(row)"></van-field>
                    <van-field v-else-if="row.colType == 4 && !row.isHidden" type="number"
                        v-model="editValues[row.colName]" :name="row.colName" :label="row.colDesc"
                        :readonly="row.isReadOnly" @change="tableDataChange(row)"></van-field>
                </div>
            </van-form>


        </van-popup>

    </div>
</body>
<script type="text/javascript">
    var vm;
    var y = 0;
    apiready = function () {
        //摄像头扫描
        var FNScanner = api.require('FNScanner');
        var scanTC80 = api.require('scanTC80');
        var escPrinter = api.require('escPrinter');
        var scanS60A = api.require('ScanS60A');
        var scanDT40 = api.require('scanDT40');
        // var scanDevice = api.require('scanDevice');

        try {
            scanTC80.updateScanSetting();
            scanTC80.registerReceiver(function (ret, err) {
                api.sendEvent({
                    name: 'scanHandler',
                    extra: {
                        scanData: ret.barcode
                    }
                })
            })
        } catch (e) { }

        try {
            //scanDevice.initSdk();
            // scanDevice.setOutScanMode({
            //     mode: 0
            // })

            // escPrinter.setPrintEventListener(function(ret, err) {
            //     // console.log(JSON.stringify(ret))
            //     // console.log(JSON.stringify(err))
            // });
            //
            // escPrinter.open();
            //
            // escPrinter.printConcentration({
            //     density: 39
            // });
            //
            // escPrinter.printQR1({
            //     offset: 2,
            //     height: 236,
            //     content: '111111'
            // });
            //
            // escPrinter.printText1({
            //     offset: 2,
            //     fontSize: 3,
            //     isBold: true,
            //     content: '111111'
            // })
            //
            //
            // escPrinter.printLine({
            //     lines: 1
            // });
            //
            // escPrinter.printLine({
            //     lines: 4
            // });
            //
            // escPrinter.printGoToNextMark1();


        } catch (e) {
            //console.log(e)
        }


        try {
            scanS60A.registerReceiver(function (ret, err) {
                api.sendEvent({
                    name: 'scanHandler',
                    extra: {
                        scanData: ret.barcode
                    }
                })
            })
        }
        catch (e) {
            console.log(e)
        }

        try {
            // scanTC80.updateScanSetting();
            scanDT40.registerReceiver(function (ret, err) {
                api.sendEvent({
                    name: 'scanHandler',
                    extra: {
                        scanData: ret.barcode
                    }
                })
            })
        } catch (e) { }



        api.setScreenOrientation({
            orientation: 'portrait_up'
        });


        //扫描监听事件
        api.addEventListener({
            name: 'scanHandler'
        }, function (ret, err) {
            //扫码结果
            var scanData = ret.value.scanData;
            vm.dealScan(scanData);
        });


        api.addEventListener({
            name: 'selectRow'
        }, function (ret, err) {
            var oriRet = ret;
            ret = ret.value.row;
            if (vm.windowSelectType == 1) {
                if (ret) {
                    //单选
                    if (oriRet.value.chooseType == 1) {
                        console.log(11111)
                        vm.formData[vm.curSelectWindowObj.baseProperty.controlName] = ret[vm.curSelectWindowObj.controlProperty.select.hiddenValue];
                        //vm.formData[vm.curSelectWindowObj.baseProperty.controlName + '_show'] = ret[vm.curSelectWindowObj.controlProperty.select.displayValue];
                        vm.$set(vm.formData, vm.curSelectWindowObj.baseProperty.controlName + '_show', ret[vm.curSelectWindowObj.controlProperty.select.displayValue]);
                        vm.dataChange(vm.curSelectWindowObj, ret);
                        vm.curSelectWindowObj = '';
                        vm.$forceUpdate();
                    }
                    //多选
                    else {
                        var selValues = [];
                        var selNames = [];
                        for (var i = 0; i < ret.length; i++) {
                            selValues.push(ret[i][vm.curSelectWindowObj.controlProperty.select.hiddenValue]);
                            selNames.push(ret[i][vm.curSelectWindowObj.controlProperty.select.displayValue]);
                        }
                        vm.formData[vm.curSelectWindowObj.baseProperty.controlName] = selValues.join(',');
                        vm.$set(vm.formData, vm.curSelectWindowObj.baseProperty.controlName + '_show', selNames.join(','));
                        vm.dataChange(vm.curSelectWindowObj, ret);
                        vm.curSelectWindowObj = '';
                        vm.$forceUpdate();
                    }


                } else {
                    vm.formData[vm.curSelectWindowObj.baseProperty.controlName] = '';
                    vm.$set(vm.formData, vm.curSelectWindowObj.baseProperty.controlName + '_show', '');
                    vm.dataChange(vm.curSelectWindowObj, ret);
                    vm.curSelectWindowObj = '';
                }
            } else if (vm.windowSelectType == 2) {
                if (ret) {
                    vm.editValues[vm.curSelectWindowObj2.colName] = ret[vm.curSelectWindowObj2.selDetail.hiddenValue];
                    //vm.formData[vm.curSelectWindowObj.baseProperty.controlName + '_show'] = ret[vm.curSelectWindowObj.controlProperty.select.displayValue];
                    vm.$set(vm.editValues, vm.curSelectWindowObj2.colName + '_show', ret[vm.curSelectWindowObj2.selDetail.displayValue]);
                    vm.editValues[vm.curSelectWindowObj2.colName + '_show', ret[vm.curSelectWindowObj2.selDetail.displayValue]];
                    vm.tableDataChange(vm.curSelectWindowObj2, ret);
                    vm.curSelectWindowObj2 = '';
                    vm.$forceUpdate();
                } else {
                    vm.editValues[vm.curSelectWindowObj2.colName] = '';
                    vm.$set(vm.editValues, vm.curSelectWindowObj2.colName + '_show', '');
                    vm.tableDataChange(vm.curSelectWindowObj2, ret);
                    vm.curSelectWindowObj2 = '';
                    vm.$forceUpdate();
                }
            } else if (vm.windowSelectType == 3) {
                if (ret) {
                    //单选
                    if (oriRet.value.chooseType == 1) {
                        vm.curSelectRowWindowObj3[vm.curSelectWindowObj3.colName] = ret[vm.curSelectWindowObj3.selDetail.hiddenValue];
                        //vm.formData[vm.curSelectWindowObj.baseProperty.controlName + '_show'] = ret[vm.curSelectWindowObj.controlProperty.select.displayValue];
                        vm.$set(vm.curSelectRowWindowObj3, vm.curSelectWindowObj3.colName + '_show', ret[vm.curSelectWindowObj3.selDetail.displayValue]);
                        vm.curSelectRowWindowObj3[vm.curSelectWindowObj3.colName + '_show'] = ret[vm.curSelectWindowObj3.selDetail.displayValue];
                        vm.itemDataChange(vm.curSelectWindowObj3, vm.curSelectRowWindowObj3, undefined, ret);
                        vm.curSelectWindowObj3 = '';
                        vm.$forceUpdate();
                    }
                    //多选
                    else {
                        var selValues = [];
                        var selNames = [];
                        //alert(JSON.stringify(vm.curSelectWindowObj3));
                        for (var i = 0; i < ret.length; i++) {
                            selValues.push(ret[i][vm.curSelectWindowObj3.selDetail.hiddenValue]);
                            selNames.push(ret[i][vm.curSelectWindowObj3.selDetail.displayValue]);
                        }
                        //vm.formData[vm.curSelectWindowObj3.colName] = selValues.join(',');
                        //vm.$set(vm.formData, vm.curSelectWindowObj3.colName + '_show', selNames.join(','));

                        vm.curSelectRowWindowObj3[vm.curSelectWindowObj3.colName] = selValues.join(',');
                        vm.curSelectRowWindowObj3[vm.curSelectWindowObj3.colName + '_show'] = selNames.join(',');
                        vm.itemDataChange(vm.curSelectWindowObj3, vm.curSelectRowWindowObj3, undefined, ret);
                        vm.curSelectWindowObj3 = '';
                        vm.$forceUpdate();
                    }
                } else {
                    vm.curSelectRowWindowObj3[vm.curSelectWindowObj3.colName] = '';
                    vm.$set(vm.curSelectRowWindowObj3, vm.curSelectWindowObj3.colName + '_show', '');
                    vm.itemDataChange(vm.curSelectWindowObj3, vm.curSelectRowWindowObj3, undefined, ret);
                    vm.curSelectWindowObj3 = '';
                    vm.$forceUpdate();
                }
            }
        })

        var enabledSubmitBtn = true;
        vm = new Vue({
            el: '#app',
            data: {
                showLoading: false,
                titleName: api.pageParam.titleName,
                showSearch: false,
                activeSubFrame: "1",
                isWatch: false,
                childFormList: [],
                reportUrl: [],
                formDesign: [],
                physicalTableName: '',
                workList: [],
                crudList: [],
                formData: [],
                isPDA: (api.deviceModel.indexOf('PDA') > -1 && api.deviceModel.indexOf('PDA') < 0) ? true : false,
                scanDisabled: false,
                scanConfig: '',
                printConfig: '',
                curFileUploader: '',
                /*组件变量*/
                showDatePicker: false,
                curDate: '',
                curDateObj: '',
                showDatePicker2: false,
                curDate2: '',
                curDateObj2: '',
                showSelectPicker: false,
                curSelect: '',
                curSelectObj: '',
                curSelectDataSource: [],
                showSelectPicker2: false,
                curSelect2: '',
                curSelectObj2: '',
                curSelectDataSource2: [],
                showSelectPicker3: false,
                curSelect3: '',
                curSelectObj3: '',
                curSelectDataSource3: [],
                curSelectRowObj3: '',

                curSelectWindowObj: '',
                curSelectWindowObj2: '',
                curSelectWindowObj3: '',
                curSelectRowWindowObj3: '',

                showDatePicker3: false,
                curDate3: '',
                curDateObj3: '',
                curDateRowObj3: '',
                windowSelectType: 1,

                childEditPopup: false,
                changeDataSource: [],
                //编辑行数据
                editFrame: {},
                editValues: {},
                editOriginValues: {},

                isUpdate: false,
                curWorkChildForm: '',
                //合计字符串
                summaryText: '',
                unWorkRoleList: [],
                //子表数据扫码
                isChildScan: false,
                //子表扫码对象
                childScanObj: '',
                selfConfirm: 0
            },
            created: function () {
                var that = this;
                // setTimeout(function(){
                //
                // },200);
                //获取当前模块业务流权限
                that.post("select * from SYS_AppRoleBFun where ModuleName='" + api.pageParam.titleName + "' and RoleID in (" + APP.getUserInfo().RoleId + ")", {
                }, function (data) {
                    that.unWorkRoleList = data.ds;
                });

                console.log(JSON.stringify(api.pageParam));
            },
            methods: {
                deleteImg() {
                    alert(1)
                },
                formatterDate(value) {
                    if (value) {
                        return value.split(' ')[0].split('T')[0];
                    } else {
                        return value;
                    }
                },

                //摄像头扫描事件
                openScan() {
                    var resultList = api.hasPermission({
                        list: ['camera']
                    });
                    if (resultList[0].granted) {
                        // 已授权，可以继续下一步操作
                        FNScanner.open({
                            autorotation: true
                        }, function (ret, err) {
                            if (ret) {
                                if (ret.content) {
                                    api.sendEvent({
                                        name: 'scanHandler',
                                        extra: {
                                            scanData: ret.content
                                        }
                                    })
                                }
                            } else {
                                vm.$toast('扫描失败');
                            }
                        });
                    } else {
                        api.confirm({
                            msg: '应用需要您的授权才能访问相机',
                            buttons: ['取消', '去设置']
                        }, function (ret) {
                            if (ret.buttonIndex == 2) {
                                api.requestPermission({
                                    list: ['camera'],
                                }, function (res) {
                                    if (res.list[0].granted) {
                                        // 已授权，可以继续下一步操作
                                        FNScanner.open({
                                            autorotation: true
                                        }, function (ret, err) {
                                            if (ret) {
                                                if (ret.content) {
                                                    api.sendEvent({
                                                        name: 'scanHandler',
                                                        extra: {
                                                            scanData: ret.content
                                                        }
                                                    })
                                                }
                                            } else {
                                                vm.$toast('扫描失败');
                                            }
                                        });
                                    }
                                });
                            }
                        });
                    }


                    // var hwScanner = api.require('hwScanner');
                    // hwScanner.defaultScanner({
                    //     formatType: 'ALL'
                    // }, function (ret) {
                    //     if (ret.status) {
                    //         api.sendEvent({
                    //             name: 'scanHandler',
                    //             extra: {
                    //                 scanData: ret.result
                    //             }
                    //         })
                    //     }
                    //     else {
                    //         vm.$toast('扫描失败');
                    //     }
                    // });
                },
                //打开打印
                openPrint() {
                    if (vm.printConfig) {
                        var script = vm.printConfig.replace(/\['/g, "vm.formData['");
                        script = script.replace(/\["/g, "vm.formData[\"");
                        eval(script);
                    }
                },
                //处理扫描结果
                dealScan(scanData) {
                    if (vm.scanConfig) {
                        var script = vm.scanConfig.replace(/\['/g, "vm.formData['");
                        script = script.replace(/\["/g, "vm.formData[\"");
                        eval(script);
                    }
                },
                isShowCheckBox(workList) {
                    // console.log(JSON.stringify(workList));
                    var isShow = false;
                    for (let i = 0; i < workList.length; i++) {
                        if (workList[i].name == '批量删除') {
                            isShow = true;
                        }
                    }
                    return isShow;
                },
                //组件事件
                //时间组件
                clickDatePicker(row) {
                    if (row.baseProperty.isReadOnly) {
                        return false;
                    } else {
                        vm.curDateObj = row;
                        vm.curDate = new Date(vm.formatterDate(vm.formData[row.baseProperty.controlName]));
                        vm.showDatePicker = true;
                    }
                },
                onDatePickerConfirm(value) {
                    vm.formData[vm.curDateObj.baseProperty.controlName] = APP.getFormatDate(value).split(' ')[0];
                    vm.dataChange(vm.curDateObj);
                    vm.showDatePicker = false;
                    vm.curDateObj = '';
                    vm.curDat = '';

                },
                onDatePickerCancel() {
                    vm.showDatePicker = false;
                    vm.curDateObj = '';
                    vm.curDat = '';
                },
                //普通下拉筛选组件
                clickSelectPicker(row) {
                    if (row.baseProperty.isReadOnly) {
                        return false;
                    } else {
                        vm.curSelectDataSource = JSLINQ(row.controlProperty.select.sqlDataSource).select(function (item) {
                            return item[row.controlProperty.select.displayValue]
                        }).ToArray();
                        vm.curSelectObj = row;
                        vm.curSelect = vm.formData[row.baseProperty.controlName + '_show'];
                        vm.showSelectPicker = true;
                    }
                },
                onSelectPickerConfirm(value, index) {
                    vm.formData[vm.curSelectObj.baseProperty.controlName] = vm.curSelectObj.controlProperty.select.sqlDataSource[index][vm.curSelectObj.controlProperty.select.hiddenValue];
                    vm.formData[vm.curSelectObj.baseProperty.controlName + '_show'] = vm.curSelectObj.controlProperty.select.sqlDataSource[index][vm.curSelectObj.controlProperty.select.displayValue];
                    vm.dataChange(vm.curSelectObj, vm.curSelectObj.controlProperty.select.sqlDataSource[index]);
                    vm.showSelectPicker = false;
                    vm.curSelectObj = '';
                    vm.curSelect = '';
                },
                onSelectPickerCancel() {
                    vm.showSelectPicker = false;
                    vm.curSelectObj = '';
                    vm.curSelect = '';
                },
                clickSelectWindowPicker(row) {
                    if (row.baseProperty.isReadOnly) {
                        return false;
                    } else {
                        vm.windowSelectType = 1;
                        vm.curSelectWindowObj = row;
                        //dataSource处理下
                        //带有@@父节点标识的字段
                        var sql = row.controlProperty.select.dataSource;
                        if (sql.indexOf('@@') >= 0) {
                            for (var name in vm.formData) {
                                var repalceValue = "'" + vm.formData[name] + "'";
                                eval("sql = sql.replace(/@@" + name + "/g, repalceValue)");
                            }
                        }
                        //.log(sql);

                        //treeDataSource  sql
                        //treeDisplayValue   
                        //treeHiddenValue  
                        //treeParentValues  
                        // console.log(JSON.stringify(row.controlProperty.select))

                        vm.openSelectScreen(sql, row.controlProperty.select.displayValue, row.controlProperty.select.hiddenValue, row.controlProperty.select.chooseType, row.controlProperty.select.treeDataSource, row.controlProperty.select.treeDisplayValue, row.controlProperty.select.treeHiddenValue, row.controlProperty.select.treeParentValues)
                    }
                },
                openSelectScreen: function (sql, displayValue, hiddenValue, chooseType, treeDataSource, treeDisplayValue, treeHiddenValue, treeParentValues) {
                    var obj = {
                        chooseType: chooseType,
                        allowClear: true,
                        showSearch: true,
                        searchKey: displayValue,
                        serverSearch: true,
                        displayValue: displayValue,
                        hiddenValue: hiddenValue,
                        isPaging: true,
                        sql: sql,
                        param: vm.formData,
                        treeObj: {
                            treeDataSource: treeDataSource,
                            treeDisplayValue: treeDisplayValue,
                            treeHiddenValue: treeHiddenValue,
                            treeParentValues: treeParentValues,
                        }
                    }
                    api.openWin({
                        name: 'selectPicker',
                        url: '../tool/selectPicker.html',
                        reload: true,
                        slidBackEnabled: false,
                        pageParam: obj
                    })
                },
                //时间组件
                clickDatePicker2(row) {
                    if (row.isReadOnly) {
                        return false;
                    } else {
                        vm.curDateObj2 = row;
                        vm.curDate2 = new Date(vm.formatterDate(vm.editValues[row.colName]));
                        vm.showDatePicker2 = true;
                    }
                },
                //上传组件
                uploaderImg(imgs) {
                    var imgArrays = [];
                    if (imgs) {
                        imgs = imgs + '';
                        var imgArray = imgs.split(',');

                        for (var i = 0; i < imgArray.length; i++) {
                            imgArrays.push({
                                url: APP.serverIP() + imgArray[i]
                            })
                        }
                    }
                    return imgArrays;
                },
                uploadFile() {
                    var controlName = vm.curFileUploader;
                    // var formId = 'jUploadForm' + controlName;  //file为input的id  
                    // var test = jQuery('#' + controlName);
                    // if (test.length > 0) {
                    //     test.remove();
                    // }
                    var url = APP.serverIP() + '/Frame/uploadImgFile?dirName=任务图片';
                    $.ajaxFileUpload({
                        type: 'POST',
                        url: url,
                        secureuri: false,
                        fileElementId: controlName,
                        dataType: 'json',
                        success: function (datas, status) {
                            preFjPath = '';
                            var file = $("#" + controlName)
                            file.after(file.clone().val(""));
                            file.remove();
                            if (datas.status == 200) {
                                vm.formData[controlName + '_files'].push({
                                    url: APP.serverIP() + datas.data.origin
                                })
                                let formDataArray = [];
                                for (var i = 0; i < vm.formData[controlName + '_files'].length; i++) {
                                    formDataArray.push(vm.formData[controlName + '_files'][i].url.replace(APP.serverIP(), ''));
                                }
                                vm.formData[controlName] = formDataArray.join(',');
                                vm.$set(vm.formData, controlName + '_files', JSON.parse(JSON.stringify(vm.formData[controlName + '_files'])));
                                vm.$forceUpdate();
                                //console.log(JSON.stringify(vm.formData[controlName+'_files']))
                                //console.log(JSON.stringify(vm.formData))

                            } else {
                                //console.log(JSON.stringify(datas));
                                vm.$toast('上传失败');
                            }
                        },
                        error: function (data, status, e) {
                            //alert(JSON.stringify(data))
                            //preFjPath = '';
                            var file = $("#" + controlName);
                            file.after(file.clone().val(""));
                            file.remove();
                            vm.$toast('上传失败');
                        }
                    });
                },
                deleteUpload(urlObj, detail) {
                    //console.log(JSON.stringify(detail));
                    var controlName = detail.name;
                    let formDataArray = [];
                    let formDataFiles = [];
                    for (var i = 0; i < vm.formData[controlName + '_files'].length; i++) {
                        if (vm.formData[controlName + '_files'][i].url != urlObj.url) {
                            formDataFiles.push(vm.formData[controlName + '_files'][i]);
                            formDataArray.push(vm.formData[controlName + '_files'][i].url.replace(APP.serverIP(), ''));
                        }
                    }
                    vm.formData[controlName + '_files'] = formDataFiles;
                    vm.$set(vm.formData, controlName + '_files', JSON.parse(JSON.stringify(formDataFiles)));
                    vm.$forceUpdate();
                    vm.formData[controlName] = formDataArray.join(',');
                },
                fileUploadClickPreview(curFileControl) {
                    vm.curFileUploader = curFileControl;
                },
                onDatePickerConfirm2(value) {
                    vm.editValues[vm.curDateObj2.colName] = APP.getFormatDate(value).split(' ')[0];
                    vm.tableDataChange(vm.curDateObj2);
                    vm.showDatePicker2 = false;
                    vm.curDateObj2 = '';
                    vm.curDat2 = '';

                },
                onDatePickerCancel2() {
                    vm.showDatePicker2 = false;
                    vm.curDateObj2 = '';
                    vm.curDat2 = '';
                },
                //普通下拉筛选组件
                clickSelectPicker2(row) {
                    if (row.isReadOnly) {
                        return false;
                    } else {
                        vm.curSelectDataSource2 = JSLINQ(row.selDetail.sqlDataSource).select(function (item) {
                            return item[row.selDetail.displayValue]
                        }).ToArray();
                        vm.curSelectObj2 = row;
                        vm.curSelect2 = vm.editValues[row.colName + '_show'];
                        vm.showSelectPicker2 = true;
                    }
                },
                onSelectPickerConfirm2(value, index) {
                    vm.editValues[vm.curSelectObj2.colName] = vm.curSelectObj2.selDetail.sqlDataSource[index][vm.curSelectObj2.selDetail.hiddenValue];
                    vm.editValues[vm.curSelectObj2.colName + '_show'] = vm.curSelectObj2.selDetail.sqlDataSource[index][vm.curSelectObj2.selDetail.displayValue];
                    vm.tableDataChange(vm.curSelectObj2);
                    vm.showSelectPicker2 = false;
                    vm.curSelectObj2 = '';
                    vm.curSelect2 = '';
                },
                onSelectPickerCancel2() {
                    vm.showSelectPicker2 = false;
                    vm.curSelectObj2 = '';
                    vm.curSelect2 = '';
                },
                clickSelectWindowPicker2(row) {
                    if (row.isReadOnly) {
                        return false;
                    } else {
                        vm.windowSelectType = 2;
                        vm.curSelectWindowObj2 = row;
                        vm.openSelectScreen(row.selDetail.dataSource, row.selDetail.displayValue, row.selDetail.hiddenValue)
                    }
                },
                //普通下拉筛选组件
                clickSelectPicker3(childForm, row, rowObj) {
                    if (row.isReadOnly) {
                        return false;
                    } else {
                        vm.curWorkChildForm = childForm;
                        vm.curSelectDataSource3 = JSLINQ(row.selDetail.sqlDataSource).select(function (item) {
                            return item[row.selDetail.displayValue]
                        }).ToArray();
                        vm.curSelectObj3 = row;
                        vm.curSelectRowObj3 = rowObj;
                        vm.curSelect3 = rowObj[row.colName + '_show'];
                        vm.showSelectPicker3 = true;
                    }
                },
                onSelectPickerConfirm3(value, index) {
                    vm.curSelectRowObj3[vm.curSelectObj3.colName] = vm.curSelectObj3.selDetail.sqlDataSource[index][vm.curSelectObj3.selDetail.hiddenValue];
                    vm.curSelectRowObj3[vm.curSelectObj3.colName + '_show'] = vm.curSelectObj3.selDetail.sqlDataSource[index][vm.curSelectObj3.selDetail.hiddenValue];
                    vm.itemDataChange(vm.curSelectObj3, vm.curSelectRowObj3);
                    vm.showSelectPicker3 = false;
                    vm.curSelectObj3 = '';
                    vm.curSelect3 = '';
                },
                onSelectPickerCancel3() {
                    vm.showSelectPicker3 = false;
                    vm.curSelectObj3 = '';
                    vm.curSelect3 = '';
                },
                clickSelectWindowPicker3(childForm, row, rowObj) {
                    if (row.isReadOnly || vm.isChildScan) {
                        return false;
                    } else {
                        vm.curWorkChildForm = childForm;
                        vm.windowSelectType = 3;
                        vm.curSelectWindowObj3 = row;
                        vm.curSelectRowWindowObj3 = rowObj;


                        //dataSource处理下
                        //带有@@父节点标识的字段
                        var sql = row.selDetail.dataSource;
                        if (sql.indexOf('@@') >= 0) {
                            for (var name in vm.formData) {
                                var repalceValue = "'" + vm.formData[name] + "'";
                                eval("sql = sql.replace(/@@" + name + "/g, repalceValue)");
                            }
                        }
                        //.log(sql);
                        vm.openSelectScreen(sql, row.selDetail.displayValue, row.selDetail.hiddenValue, row.selDetail.chooseType, row.selDetail.treeDataSource, row.selDetail.treeDisplayValue, row.selDetail.treeHiddenValue, row.selDetail.treeParentValues)
                    }
                },
                scanSelectWindowPicker3(childForm, row, rowObj) {
                    vm.isChildScan = true;
                    // for (var i = 0; i < childForm.tableData.length; i++) {
                    //     childForm.tableData[i].checked = false;
                    // }
                    // rowObj.checked = true;
                    vm.childScanObj = rowObj;
                    vm.$forceUpdate();
                    vm.openScan();


                    setTimeout(function () {
                        vm.isChildScan = false;
                    }, 200);
                },
                clickDatePicker3(childForm, row, rowObj) {
                    if (row.isReadOnly) {
                        return false;
                    } else {
                        vm.curDateObj3 = row;
                        vm.curDateRowObj3 = rowObj;
                        vm.curWorkChildForm = childForm;
                        vm.curDate3 = new Date(vm.formatterDate(vm.curDateRowObj3[row.colName]));
                        vm.showDatePicker3 = true;
                    }
                },
                onDatePickerConfirm3(value) {
                    vm.curDateRowObj3[vm.curDateObj3.colName] = APP.getFormatDate(value).split(' ')[0];
                    vm.itemDataChange(vm.curDateObj3, vm.curDateRowObj3);
                    vm.showDatePicker3 = false;
                    vm.curDateObj3 = '';
                    vm.curDat3 = '';

                },
                onDatePickerCancel3() {
                    vm.showDatePicker3 = false;
                    vm.curDateObj3 = '';
                    vm.curDat3 = '';
                },
                confirmEditPopup() {
                    vm.editOriginValues = vm.editValues;
                    vm.curWorkChildForm = vm.editFrame;
                    //console.log(JSON.stringify(vm.editFrame));
                    var curEditRow = '';
                    for (var i = 0; i < vm.editFrame.tableData.length; i++) {
                        if (vm.editFrame.tableData[i]['objNo'] == vm.editOriginValues['objNo']) {
                            vm.editFrame.tableData[i] = vm.editOriginValues;
                            curEditRow = vm.editFrame.tableData[i];
                        }
                    }
                    vm.$set(vm.editFrame, "tableData", JSON.parse(JSON.stringify(vm.editFrame.tableData)));
                    vm.refreshChildCol(vm.editFrame);
                    vm.childEditPopup = false;
                    vm.updateRow(curEditRow);
                    vm.$forceUpdate();
                },
                //数据变化的回调函数
                dataChange: function (formCol, returnValue) {
                    if (formCol.baseProperty.controlCallBack) {
                        var script = formCol.baseProperty.controlCallBack.replace(/\['/g, "vm.formData['");
                        script = script.replace(/\["/g, "vm.formData[\"");
                        eval(script);
                        vm.refreshInitActualName();
                    }
                    if (formCol.baseProperty.controlChange) {
                        var script = formCol.baseProperty.controlChange.replace(/\['/g, "vm.formData['");
                        script = script.replace(/\["/g, "vm.formData[\"");
                        eval(script);
                        vm.refreshInitActualName();
                    }
                },
                tableDataChange: function (formCol, returnValue) {
                    if (formCol.colCallBack) {
                        var script = formCol.colCallBack.replace(/\['/g, "vm.editValues['");
                        script = script.replace(/\["/g, "vm.editValues[\"");
                        eval(script);
                    }
                    if (formCol.colChange) {
                        var script = formCol.colChange.replace(/\['/g, "vm.editValues['");
                        script = script.replace(/\["/g, "vm.editValues[\"");
                        eval(script);
                    }
                },
                itemDataChange: function (formCol, curRow, childForm, returnValue) {
                    if (childForm) {
                        vm.curWorkChildForm = childForm;
                    }
                    //更新修改行数据
                    vm.updateRow(curRow);

                    if (formCol.colCallBack) {
                        var script = formCol.colCallBack.replace(/\['/g, "curRow['");
                        script = script.replace(/\["/g, "curRow[\"");
                        eval(script);
                    }
                    if (formCol.colChange) {
                        var script = formCol.colChange.replace(/\['/g, "curRow['");
                        script = script.replace(/\["/g, "curRow[\"");
                        eval(script);
                    }
                },
                //按钮显示条件判断
                btn_showCondition(type, btn) {
                    try {
                        var _this = this;
                        var result = true;
                        var showScript = "";

                        //普通crud
                        if (type == 1) {
                            if (btn == "新增") {
                                showScript = _this.crudList[0].show;
                            }
                            else if (btn == "编辑") {
                                showScript = _this.crudList[1].show;
                            }
                            else if (btn == "删除") {
                                showScript = _this.crudList[2].show;
                            }
                            //判断是否在禁止业务流中存在
                            for (var z = 0; z < _this.unWorkRoleList.length; z++) {
                                if (btn == _this.unWorkRoleList[z].FunName) {
                                    result = false;
                                }
                            }
                        }
                        //业务按钮
                        else if (type == 2) {
                            //判断是否在禁止业务流中存在

                            for (var z = 0; z < _this.unWorkRoleList.length; z++) {
                                if (btn.name == _this.unWorkRoleList[z].FunName) {
                                    result = false;
                                }
                            }
                            if (result) {
                                showScript = btn.show;
                            }
                        }
                        //调入按钮
                        else if (type == 3) {
                            showScript = btn.btnShow;
                        }
                        if (showScript) {
                            var script = showScript.replace(/\['/g, "_this.formData['");
                            script = script.replace(/\["/g, "_this.formData[\"");
                            //console.log(_this.formData['BeginStatus'])
                            eval("result=(" + script + ")");
                        }
                        return result;
                    } catch (e) {
                        return false;
                    }
                },
                //生成GUID
                guid() {
                    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
                        var r = Math.random() * 16 | 0,
                            v = c == 'x' ? r : (r & 0x3 | 0x8);
                        return v.toString(16);
                    });
                },
                pageInit(isRefreshChildWindow) {
                    //子表数据要有值，同时
                    if (vm.childFormList.length > 0) {
                        //if (vm.childFormList.length > 0 && $("#keyName").val() != "" && $("#keyValue").val() != "") {
                        vm.childFormSelectName = vm.childFormList[0].name;
                        for (var i = 0; i < vm.childFormList.length; i++) {
                            //业务处理
                            vm.childPageInit(vm.childFormList[i]);
                        }
                        $(".mainForm").css("height", "40%");
                        $(".subFrame").css("height", "60%");
                    } else {
                        $(".mainForm").css("height", "100%");
                        $(".subFrame").css("height", "0%");
                    }
                    vm.controlInit();
                },
                childPageInit(childObj) {
                    APP.ajax2('/AppFormList/GetDataByName', {
                        objName: childObj.name
                    }, function (data) {
                        var filterCondition = data.ds[0]["filterCondition"];
                        if (filterCondition == null) {
                            filterCondition = "";
                        }
                        vm.childTableConfig({
                            childObj: childObj,
                            columns: JSON.parse(data.ds[0]["columnsConfig"]),
                            workList: JSON.parse(data.ds[0]["worksConfig"]),
                            crudList: JSON.parse(data.ds[0]["crudConfig"]),
                            params: {
                                isFormList: data.ds[0]["isFormList"],
                                physicalTableName: data.ds[0]["physicalTableName"],
                                isPaging: data.ds[0]["isPaging"],
                                filterCondition: filterCondition,
                                defaultOrder: data.ds[0]["defaultOrder"],
                                detailName: data.ds[0]["detailName"],
                                isFormEdit: false,
                                rowClassCol: data.ds[0]["rowClassCol"],
                                onReadyCallBack: data.ds[0]["onReadyCallBack"],
                                colClassCol: data.ds[0]["colClassCol"]
                            }
                        })
                    });
                },
                //子表配置参数
                childTableConfig(options) {
                    var curChildObj = options.childObj;
                    vm.$set(curChildObj, "columns", options.columns);
                    vm.$set(curChildObj, "workList", options.workList);
                    vm.$set(curChildObj, "crudList", options.crudList);
                    vm.$set(curChildObj, "params", options.params);
                    var pdaHeight = 0;
                    if (api.deviceModel.indexOf('PDA') > -1 || api.deviceModel.indexOf('DT40') > -1) {
                        pdaHeight = 40 / 0.9;
                    }


                    if (options.workList.length > 0) {
                        vm.$set(curChildObj, "tableHeight", (window.innerHeight / 0.9) * 0.6 - (135) / 0.9 + pdaHeight);
                    } else {
                        vm.$set(curChildObj, "tableHeight", (window.innerHeight / 0.9) * 0.6 - 135 / 0.9 + pdaHeight);
                    }
                    var filterCondition = '1=1';
                    if (options.params.filterCondition) {
                        filterCondition += ' and ' + options.params.filterCondition;
                    }
                    let connectParams = vm.formData[curChildObj['connectParams']];
                    if (!connectParams) {
                        filterCondition += " and 1=0 ";
                    } else {
                        filterCondition += " and " + curChildObj['connectParams'] + "='" + connectParams + "'";
                    }
                    vm.$set(curChildObj, "tableData", []);
                    if (curChildObj.showType == 'table') {
                        APP.ajax2('/SQLData/GetDataByPhysicalTableNameByQueryPaging', {
                            tableName: options.params.physicalTableName,
                            columns: [],
                            currentCol: '',
                            pageIndex: 1,
                            pageSize: 9999,
                            isForm: options.params.isFormList || true,
                            filterCondition: filterCondition,
                            defaultOrder: options.params.defaultOrder || ''
                        }, function (data) {
                            var tableData = data.ds;
                            for (var i = 0; i < tableData.length; i++) {
                                tableData[i].objNo = (i + 1).toString();
                                if (!tableData[i].guid) {
                                    tableData[i].guid = vm.guid();
                                }
                            }

                            vm.$set(curChildObj, "tableData", tableData);
                            vm.refreshChildCol(curChildObj);


                        }, function () {
                            vm.tableData = [];
                        });
                    } else {
                        if (!curChildObj.isPaging) {
                            curChildObj.pageSize = 9999;
                        }
                        APP.ajax2('/SQLData/GetDataByPhysicalTableNameByQueryPaging', {
                            tableName: options.params.physicalTableName,
                            columns: [],
                            currentCol: '',
                            pageIndex: curChildObj.pageIndex,
                            pageSize: curChildObj.pageSize,
                            isForm: options.params.isFormList || true,
                            filterCondition: filterCondition,
                            defaultOrder: options.params.defaultOrder || ''
                        }, function (data) {
                            var tableData = data.ds;
                            curChildObj.showListLoading = false;
                            //if (!curChildObj.pageIndex) {
                            curChildObj.pageIndex == 1;
                            vm.$set(curChildObj, "tableData", data.ds);

                            //}
                            // if (curChildObj.pageIndex == 1) {

                            // } else {
                            //     curChildObj.tableData = curChildObj.tableData.concat(data.ds);
                            // }

                            for (var i = 0; i < curChildObj.tableData.length; i++) {
                                curChildObj.tableData[i].objNo = (i + 1).toString();
                                if (!curChildObj.tableData[i].guid) {
                                    curChildObj.tableData[i].guid = vm.guid();
                                }
                            }
                            if (data.ds1.length > 0) {
                                //绑定总长度
                                if (curChildObj.tableData.length >= parseInt(data.ds1[0]["@TotalCount"])) {
                                    curChildObj.finished = true;
                                }
                            }
                            curChildObj.pageIndex = curChildObj.pageIndex + 1;
                            // for(var i=0;i<tableData.length;i++){
                            //   tableData[i].objNo = (i+1).toString();
                            // }
                            //
                            // vm.$set(curChildObj, "tableData",tableData );
                            vm.refreshChildCol(curChildObj);


                        }, function () {
                            vm.tableData = [];
                        });
                    }
                },
                //刷新列数据
                refreshChildCol(childObj) {
                    for (var i = 0; i < childObj.columns.length; i++) {
                        //下拉框数据加载
                        if (childObj.columns[i].colType == 2 && childObj.columns[i].selDetail.type < 3) {
                            var sql = childObj.columns[i].selDetail.dataSource;
                            data = vm.changeDataAjax(sql, "1=1");
                            vm.$set(childObj.columns[i].selDetail, "sqlDataSource", data);
                        } else if (childObj.columns[i].colType == 2 && childObj.columns[i].selDetail.type == 3) {

                            var valueList = [];
                            for (var j = 0; j < childObj.tableData.length; j++) {
                                //if (vm.tableData[j][vm.columns[i].selDetail.hiddenValue] != null && vm.tableData[j][vm.columns[i].selDetail.hiddenValue] != undefined && vm.tableData[j][vm.columns[i].selDetail.hiddenValue] != '') {
                                //    valueList.push("'" + vm.tableData[j][vm.columns[i].selDetail.hiddenValue] + "'");
                                //}
                                if (childObj.tableData[j][childObj.columns[i].colName]) {
                                    for (var k = 0; k < childObj.tableData[j][childObj.columns[i].colName].toString().split(',').length; k++) {
                                        valueList.push("'" + childObj.tableData[j][childObj.columns[i].colName].toString().split(',')[k] + "'");
                                    }
                                }
                            }
                            //var sql = "select * from (" + vm.columns[i].selDetail.dataSource + ")t";
                            if (valueList.length > 0) {
                                var data = vm.changeDataAjax(childObj.columns[i].selDetail.dataSource, childObj.columns[i].selDetail.hiddenValue + " in (" + valueList.join(',') + ") ");
                                vm.$set(childObj.columns[i].selDetail, "sqlDataSource", data);
                            } else {
                                vm.$set(childObj.columns[i].selDetail, "sqlDataSource", []);
                            }
                        }
                    }
                },
                //显示真实值
                showActualValue(value, colObject, originValue, curRow) {
                    if (originValue) {
                        return originValue;
                    }
                    if (colObject.selDetail.sqlDataSource) {
                        if (colObject.selDetail.chooseType == 1) {
                            var curObject = JSLINQ(colObject.selDetail.sqlDataSource).where(function (item) {
                                return item[colObject.selDetail.hiddenValue] == value
                            }).ToArray();
                            if (curObject.length > 0) {
                                return curObject[0][colObject.selDetail.displayValue];
                            } else if (originValue) {
                                return originValue;
                            } else {
                                return '';
                            }
                        }
                        else {
                            if (value) {
                                var newValues = [];
                                value = value + '';
                                console.log(JSON.stringify(colObject.selDetail.sqlDataSource));
                                for (var i = 0; i < value.split(',').length; i++) {
                                    var curObject = JSLINQ(colObject.selDetail.sqlDataSource).where(function (item) {
                                        return item[colObject.selDetail.hiddenValue] == value.split(',')[i]
                                    }).ToArray();
                                    if (curObject.length > 0) {
                                        newValues.push(curObject[0][colObject.selDetail.displayValue]);
                                    }
                                }
                                if (newValues.length > 0) {
                                    //alert('33334444'+JSON.stringify(vm.childFormList[0].tableData))
                                    //alert(originValue)
                                    if (originValue && originValue.indexOf(newValues.join(',')) >= 0) {
                                        return originValue;
                                    }
                                    else {
                                        if (curRow) {
                                            curRow[colObject.colName + '_show'] = newValues.join(',')
                                        }
                                        return newValues.join(',')
                                    }

                                }
                                else if (originValue) {
                                    return originValue;
                                }

                            }
                        }
                    } else {
                        return '';
                    }

                    //return '';
                },


                editChildRow(childObj, valObj) {
                    vm.editFrame = childObj;
                    vm.editValues = JSON.parse(JSON.stringify(valObj));
                    vm.editOriginValues = valObj;
                    for (var i = 0; i < vm.editFrame.columns.length; i++) {
                        if (vm.editFrame.columns[i].colType == 2) {
                            var v = vm.editValues[vm.editFrame.columns[i].colName];
                            vm.editValues[vm.editFrame.columns[i].colName + '_show'] = vm.showActualValue(v, vm.editFrame.columns[i]);
                        }
                        vm.tableDataChange(vm.editFrame.columns[i]);

                    }
                    vm.childEditPopup = true;
                },
                delChildRow(childObj, valObj) {
                    vm.$dialog.confirm({
                        title: '提示',
                        message: '是否删除此行？',
                    }).then(() => {
                        vm.curWorkChildForm = childObj;

                        vm.delRow(valObj);


                        childObj.tableData = JSLINQ(childObj.tableData).where(function (item) {
                            return item.guid != valObj.guid;
                        }).ToArray();
                        for (var i = 0; i < childObj.tableData.length; i++) {
                            childObj.tableData[i].objNo = (i + 1).toString();
                            if (!childObj.tableData[i].guid) {
                                childObj.tableData[i].guid = vm.guid();
                            }
                        }
                    })
                        .catch(() => { })
                },

                //重新赋值
                refreshInitActualName: function () {
                    for (var i = 0; i < vm.formDesign.length; i++) {
                        if (vm.formDesign[i].baseProperty.controlType == "select") {
                            //下拉框数据加载
                            if (vm.formDesign[i].controlProperty.select.type < 3) {
                                var sql = vm.formDesign[i].controlProperty.select.dataSource;
                                $.ajax({
                                    url: APP.serverIP() + "/SQLData/GetDataBySql",
                                    async: false,
                                    data: {
                                        sql: sql
                                    },
                                    type: "post",
                                    dataType: 'json',
                                    success: function (data) {
                                        if (data.status == 200) {
                                            vm.$set(vm.formDesign[i].controlProperty.select, "sqlDataSource", data.data.ds);
                                            vm.$set(vm.formDesign[i].controlProperty.select, "originDataSource", data.data.ds);

                                            //判断隐藏值类型和当前赋值类型是否一致
                                            if (data.data.ds.length > 0 && vm.formData[vm.formDesign[i].baseProperty.controlName]) {
                                                var dataType = typeof (data.data.ds[0][vm.formDesign[i].controlProperty.select.hiddenValue]);
                                                if (dataType != typeof (vm.formData[vm.formDesign[i].baseProperty.controlName])) {
                                                    if (dataType == "int" || dataType == "number") {
                                                        vm.formData[vm.formDesign[i].baseProperty.controlName] = parseInt(vm.formData[vm.formDesign[i].baseProperty.controlName]);
                                                    } else if (dataType == "boolean") {
                                                        vm.formData[vm.formDesign[i].baseProperty.controlName] = Boolean(parseInt(vm.formData[vm.formDesign[i].baseProperty.controlName]));
                                                    }
                                                } else {
                                                    vm.formData[vm.formDesign[i].baseProperty.controlName] = vm.formData[vm.formDesign[i].baseProperty.controlName];
                                                }
                                                vm.formData[vm.formDesign[i].baseProperty.controlName + '_show'] = ''
                                                var curDs = JSLINQ(data.data.ds).where(function (item) {
                                                    return item[vm.formDesign[i].controlProperty.select.hiddenValue] == vm.formData[vm.formDesign[i].baseProperty.controlName]
                                                }).ToArray();
                                                if (curDs.length > 0) {
                                                    vm.formData[vm.formDesign[i].baseProperty.controlName + '_show'] = curDs[0][vm.formDesign[i].controlProperty.select.displayValue]
                                                }
                                            }
                                        }
                                    }
                                });
                            } else if (vm.formDesign[i].controlProperty.select.type == 3) {
                                if (vm.formDesign[i].controlProperty.select.chooseType == 1) {
                                    var valueList = [];
                                    if (vm.formData[vm.formDesign[i].baseProperty.controlName] != undefined && vm.formData[vm.formDesign[i].baseProperty.controlName] != "") {
                                        valueList.push("'" + vm.formData[vm.formDesign[i].baseProperty.controlName] + "'");
                                    }
                                    var sql = "select * from (" + vm.formDesign[i].controlProperty.select.dataSource + ")t";
                                    if (valueList.length > 0) {
                                        sql += " where " + vm.formDesign[i].controlProperty.select.hiddenValue + " in (" + valueList.join(',') + ") ";
                                        $.ajax({
                                            url: "s://" + APP.serverIP() + "/SQLData/GetDataBySql",
                                            async: false,
                                            data: {
                                                sql: sql
                                            },
                                            type: "post",
                                            dataType: 'json',
                                            success: function (data) {
                                                if (data.status == 200) {
                                                    //options.formDesign[i].controlProperty.select["sqlDataSource"] = data.data.ds;
                                                    //options.formDesign[i].controlProperty.select["originDataSource"] = data.data.ds;
                                                    vm.$set(vm.formDesign[i].controlProperty.select, "sqlDataSource", data.data.ds);
                                                    vm.$set(vm.formDesign[i].controlProperty.select, "originDataSource", data.data.ds);
                                                    //绑定固定值
                                                    vm.$set(vm.formDesign[i].controlProperty.select, "actualName", "");
                                                    //options.formDesign[i].controlProperty.select["actualName"] = "";
                                                    var actualList = JSLINQ(data.data.ds).where(function (item) {
                                                        return item[vm.formDesign[i].controlProperty.select.hiddenValue] == vm.formData[vm.formDesign[i].baseProperty.controlName]
                                                    }).ToArray();
                                                    if (actualList.length > 0) {
                                                        vm.$set(vm.formDesign[i].controlProperty.select, "actualName", actualList[0][vm.formDesign[i].controlProperty.select.displayValue]);
                                                        //options.formDesign[i].controlProperty.select["actualName"] = actualList[0][options.formDesign[i].controlProperty.select.displayValue];
                                                    }
                                                }
                                            }
                                        });
                                    } else {
                                        vm.$set(vm.formDesign[i].controlProperty.select, "sqlDataSource", []);
                                        //options.formDesign[i].controlProperty.select["sqlDataSource"] = [];
                                        vm.$set(vm.formDesign[i].controlProperty.select, "originDataSource", []);
                                        //options.formDesign[i].controlProperty.select["originDataSource"] = [];
                                        vm.$set(vm.formDesign[i].controlProperty.select, "actualName", "");
                                        //options.formDesign[i].controlProperty.select["actualName"] = [];

                                    }
                                } else {
                                    var valueList = "";
                                    if (vm.formData[vm.formDesign[i].baseProperty.controlName] != undefined && vm.formData[vm.formDesign[i].baseProperty.controlName] != "") {
                                        let valueArray = [];
                                        valueArray = vm.formData[vm.formDesign[i].baseProperty.controlName].toString().split(',');
                                        for (var q = 0; q < valueArray.length; q++) {
                                            valueArray[q] = "'" + valueArray[q] + "'";
                                        }
                                        valueList = valueArray.join(',');
                                    }
                                    var sql = "select * from (" + vm.formDesign[i].controlProperty.select.dataSource + ")t";
                                    if (valueList) {
                                        sql += " where " + vm.formDesign[i].controlProperty.select.hiddenValue + " in (" + valueList + ") ";
                                        // console.log(sql);
                                        $.ajax({
                                            url: APP.serverIP() + "/SQLData/GetDataBySql",
                                            async: false,
                                            data: {
                                                sql: sql
                                            },
                                            type: "post",
                                            dataType: 'json',
                                            success: function (data) {
                                                if (data.status == 200) {
                                                    vm.$set(vm.formDesign[i].controlProperty.select, "sqlDataSource", data.data.ds);
                                                    vm.$set(vm.formDesign[i].controlProperty.select, "originDataSource", data.data.ds);
                                                    //绑定固定值
                                                    vm.$set(vm.formDesign[i].controlProperty.select, "actualName", "");
                                                    var displayValue = JSLINQ(data.data.ds).select(function (item) {
                                                        return item[vm.formDesign[i].controlProperty.select.displayValue]
                                                    }).ToArray().join(',');
                                                    vm.$set(vm.formDesign[i].controlProperty.select, "actualName", displayValue);
                                                }
                                            }
                                        });
                                    } else {
                                        vm.$set(vm.formDesign[i].controlProperty.select, "actualName", "");
                                        vm.$set(vm.formDesign[i].controlProperty.select, "sqlDataSource", []);
                                        //vm.formDesign[i].controls[j].controlProperty.select["sqlDataSource"] = [];
                                        vm.$set(vm.formDesign[i].controlProperty.select, "originDataSource", []);
                                    }
                                }
                            }
                        }
                    }
                },

                //控件属性赋值
                controlInit: function () {
                    //新增时初始化控件默认选中功能
                    var isFirstControl = false;

                    //控件属性赋值
                    for (var i = 0; i < vm.formDesign.length; i++) {
                        var controlNo = vm.formDesign[i].baseProperty.controlNo;
                        if (controlNo) {
                            var currentDom = $("[controlNo='" + controlNo + "']");
                            //必填项选择
                            if (vm.formDesign[i].baseProperty.isRequired) {
                                var domHtml = currentDom.parent().parent().prev().html();

                                if (currentDom.parent().parent().prev().find("i").length == 0) {
                                    currentDom.parent().parent().prev().html("<i style='color:red;margin-right: 3px;font-style: inherit;'>*</i>" + currentDom.parent().parent().prev().html());
                                }


                                // currentDom.parent().parent().parent().css({
                                //     background: '#fbf5bf'
                                // });
                            }
                            // else {
                            //     currentDom.parent().parent().parent().css({
                            //         background: '#ffffff'
                            //     });
                            // }
                        }

                    }
                },


                post(sql, param, callBack) {
                    param["sql"] = sql;
                    $.ajax({
                        url: APP.serverIP() + "/SQLData/QuerySql",
                        type: "post",
                        dataType: "json",
                        async: true,
                        data: param,
                        success: function (data) {
                            if (data.status == 200) {
                                callBack(data.data);
                            } else {
                                layer.alert(data.msg);
                            }
                        },
                        error: function (a, b, c) {
                            //console.log(JSON.stringify(a));
                        }
                    });
                    //vm.handleSizeChange(vm.paging.pageIndex);
                },
                //获取默认值
                //系统默认常量时间
                getSYDefaultValue(funcName) {
                    if (funcName.indexOf("getdate()") >= 0) {
                        var date;
                        if (funcName == "getdate()") {
                            date = new Date();
                        } else {
                            date = new Date();
                            Date.prototype.DateAdd = function (strInterval, Number) {
                                var dtTmp = this;
                                switch (strInterval) {
                                    case 's':
                                        return new Date(Date.parse(dtTmp) + (1000 * Number));
                                    case 'n':
                                        return new Date(Date.parse(dtTmp) + (60000 * Number));
                                    case 'h':
                                        return new Date(Date.parse(dtTmp) + (3600000 * Number));
                                    case 'd':
                                        return new Date(Date.parse(dtTmp) + (86400000 * Number));
                                    case 'w':
                                        return new Date(Date.parse(dtTmp) + ((86400000 * 7) * Number));
                                    case 'q':
                                        return new Date(dtTmp.getFullYear(), (dtTmp.getMonth()) + Number * 3, dtTmp.getDate(), dtTmp.getHours(), dtTmp.getMinutes(), dtTmp.getSeconds());
                                    case 'm':
                                        return new Date(dtTmp.getFullYear(), (dtTmp.getMonth()) + Number, dtTmp.getDate(), dtTmp.getHours(), dtTmp.getMinutes(), dtTmp.getSeconds());
                                    case 'y':
                                        return new Date((dtTmp.getFullYear() + Number), dtTmp.getMonth(), dtTmp.getDate(), dtTmp.getHours(), dtTmp.getMinutes(), dtTmp.getSeconds());
                                }
                            }
                            var addFun = funcName.split('.')[1];
                            eval("date=date." + addFun);
                        }
                        var seperator1 = "-";
                        var seperator2 = ":";
                        var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
                        var strDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
                        var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate +
                            " " + date.getHours() + seperator2 + date.getMinutes() +
                            seperator2 + date.getSeconds();
                        return currentdate;
                    } else if (funcName.indexOf("$.cookie") >= 0) {
                        return eval(funcName);
                    } else if (funcName.indexOf('func:') >= 0) {
                        return eval(funcName.split(':')[1]);
                    } else if (funcName.indexOf("@") >= 0) {
                        if (funcName == '@P_UserID' || funcName == '@P_UserCode') {
                            return {
                                P_UserID: APP.getUserInfo().UserID,
                                P_UserName: APP.getUserInfo().UserName,
                                P_UserCode: APP.getUserInfo().UserCode
                            }
                        }
                    } else {
                        return funcName;
                    }
                },
                /*系统函数结束*/
                /*change获取数据机制处理
                  用于change过程中反复调用后台处理的机制问题
                */
                changeDataAjax: function (datasource, query) {
                    if (datasource.indexOf('@@') >= 0) {
                        for (var name in vm.formData) {
                            var repalceValue = "'" + vm.formData[name] + "'";
                            eval("datasource = datasource.replace(/@@" + name + "/g, repalceValue)");
                        }
                        //console.log(sql);
                    }
                    var dsResult = JSLINQ(vm.changeDataSource).where(function (item) {
                        return item.datasource == datasource && item.query == query;
                    }).ToArray();
                    if (dsResult.length == 0) {
                        var returnData = [];
                        var sql = "select * from (" + datasource + ")t";
                        sql += " where " + query;
                        $.ajax({
                            url: APP.serverIP() + "/SQLData/GetDataBySql",
                            async: false,
                            data: {
                                sql: sql
                            },
                            type: "post",
                            dataType: 'json',
                            success: function (data) {
                                if (data.status == 200) {
                                    returnData = data.data.ds;
                                    vm.changeDataSource.push({
                                        datasource: datasource,
                                        query: query,
                                        data: returnData
                                    });
                                }
                            }
                        });
                        return returnData;
                    } else {
                        return dsResult[0].data;
                    }
                },
                //验证必填项
                valitedRequired() {
                    var resultObj = {
                        status: 200,
                        msg: ""
                    };
                    for (var i = 0; i < vm.formDesign.length; i++) {
                        if (vm.formDesign[i].baseProperty.isRequired) {
                            if (vm.formData[vm.formDesign[i].baseProperty.controlName] === "" || vm.formData[vm.formDesign[i].baseProperty.controlName] === null) {
                                resultObj = {
                                    status: 500,
                                    msg: vm.formDesign[i].baseProperty.labelName + "字段不能为空!"
                                };
                            }
                        }
                    }
                    return resultObj;
                },
                valitedChildForm(childForm, createObjs, updateObjs) {
                    var valited = true;
                    var valitedColumn = "";
                    var index = 0;
                    for (var i = 0; i < childForm.columns.length; i++) {
                        if (childForm.columns[i].isRequired) {
                            for (var j = 0; j < createObjs.length; j++) {
                                if (createObjs[j][childForm.columns[i].colName] === undefined || createObjs[j][childForm.columns[i].colName] === null || createObjs[j][childForm.columns[i].colName] === "") {
                                    index = j;
                                    valited = false;
                                    valitedColumn = childForm.columns[i].colDesc;
                                }
                            }
                            for (var j = 0; j < updateObjs.length; j++) {
                                if (updateObjs[j][childForm.columns[i].colName] === undefined || updateObjs[j][childForm.columns[i].colName] === null || updateObjs[j][childForm.columns[i].colName] === "") {
                                    index = j;
                                    valited = false;
                                    valitedColumn = childForm.columns[i].colDesc;
                                }
                            }
                        }
                    }
                    for (var j = 0; j < createObjs.length; j++) {
                        if (!createObjs[j].objNo) {
                            index = j;
                            valited = false;
                            valitedColumn = "数据行";
                        }
                    }
                    for (var j = 0; j < updateObjs.length; j++) {
                        if (!updateObjs[j].objNo) {
                            index = j;
                            valited = false;
                            valitedColumn = "数据行";
                        }
                    }
                    return {
                        valited: valited,
                        valitedColumn: valitedColumn,
                        index: index
                    };
                },
                //自定义按钮事件
                selfMainWorkHandler(work) {
                    vm.selfConfirm = vm.selfConfirm + 1;
                    console.log('out' + vm.selfConfirm);


                    if (vm.selfConfirm > 1) {
                        // layer.alert('请勿频繁操作');
                        setTimeout(function () {
                            vm.selfConfirm = 0;
                        }, 3000);
                    }
                    else {
                        setTimeout(function () {
                            var script = work.script.replace(/\['/g, "vm.formData['");
                            script = script.replace(/\["/g, "vm.formData[\"");
                            //console.log(vm.formData['BeginStatus'])
                            eval(script);

                        }, 500);
                    }






                },
                selfWorkHandler(childForm, btn) {

                    vm.curWorkChildForm = childForm;
                    var script = btn.script.replace(/\['/g, "vm.formData['");
                    script = script.replace(/\["/g, "vm.formData[\"");
                    eval(script);
                },
                //清空行
                removeAllRow(subFrame) {
                    var curSubFrame = JSLINQ(vm.childFormList).where(function (item) {
                        return item.title == subFrame
                    }).ToArray();
                    if (curSubFrame.length > 0) {
                        curSubFrame = curSubFrame[0];
                    }
                    curSubFrame.tableData = [];
                    curSubFrame.crud = {
                        create: [],
                        update: [],
                        delete: []
                    }
                },
                //新增行
                insertRow(newRecord, subFrame) {
                    var curSubFrame = JSLINQ(vm.childFormList).where(function (item) {
                        return item.title == subFrame
                    }).ToArray();
                    if (curSubFrame.length > 0) {
                        curSubFrame = curSubFrame[0];
                    }
                    var defaultParams = (curSubFrame.defaultParams + '').split(',');
                    var defaultChildParams = (curSubFrame.defaultChildParams + '').split(',');
                    for (var j = 0; j < defaultParams.length; j++) {
                        newRecord[defaultChildParams[j]] = vm.formData[defaultParams[j]];
                    }
                    var transParams = (curSubFrame.transParams + '').split(',');
                    var transChildParams = (curSubFrame.transChildParams + '').split(',');
                    for (var j = 0; j < transParams.length; j++) {
                        newRecord[transChildParams[j]] = vm.formData[transParams[j]];
                    }
                    curSubFrame.tableData.push(newRecord);
                    for (var i = 0; i < curSubFrame.tableData.length; i++) {
                        curSubFrame.tableData[i].objNo = (i + 1).toString();
                        if (!curSubFrame.tableData[i].guid) {
                            curSubFrame.tableData[i].guid = vm.guid();
                        }
                    }
                    curSubFrame.crud.create.push(newRecord);
                    //vm.editFrame = curSubFrame;
                },
                //修改行
                updateRow(modifyRecord) {
                    //不存在在新增中
                    if (JSLINQ(vm.curWorkChildForm.crud.create).where(function (item) {
                        return item.guid == modifyRecord.guid
                    }).ToArray().length == 0) {
                        //同时也不存在在更新中
                        if (JSLINQ(vm.curWorkChildForm.crud.update).where(function (item) {
                            return item.guid == modifyRecord.guid
                        }).ToArray().length == 0) {
                            vm.curWorkChildForm.crud.update.push(modifyRecord)
                        } else {
                            for (var i = 0; i < vm.curWorkChildForm.crud.update.length; i++) {
                                if (vm.curWorkChildForm.crud.update[i].guid == modifyRecord.guid) {
                                    vm.curWorkChildForm.crud.update[i] = modifyRecord;
                                }
                            }
                        }
                    } else {
                        for (var i = 0; i < vm.curWorkChildForm.crud.create.length; i++) {
                            if (vm.curWorkChildForm.crud.create[i].guid == modifyRecord.guid) {
                                vm.curWorkChildForm.crud.create[i] = modifyRecord;
                            }
                        }
                    }
                },
                //删除所有行
                clearAllRow(subFrame) {
                    var curSubFrame = JSLINQ(vm.childFormList).where(function (item) {
                        return item.title == subFrame
                    }).ToArray();
                    if (curSubFrame.length > 0) {
                        curSubFrame = curSubFrame[0];
                    }
                    vm.curWorkChildForm = curSubFrame;

                    for (var i = 0; i < vm.curWorkChildForm.tableData.length; i++) {
                        vm.delRow(vm.curWorkChildForm.tableData[i]);
                    }
                    vm.curWorkChildForm.tableData = [];
                },
                //删除被勾选行
                clearCheckRow(subFrame) {
                    var curSubFrame = JSLINQ(vm.childFormList).where(function (item) {
                        return item.title == subFrame
                    }).ToArray();
                    if (curSubFrame.length > 0) {
                        curSubFrame = curSubFrame[0];
                    }
                    vm.curWorkChildForm = curSubFrame;

                    for (var i = 0; i < vm.curWorkChildForm.tableData.length; i++) {
                        if (vm.curWorkChildForm.tableData[i].checked) {
                            vm.delRow(vm.curWorkChildForm.tableData[i]);
                        }
                        else {
                            vm.curWorkChildForm.tableData[i].checked = false;
                        }
                    }
                    vm.curWorkChildForm.tableData = JSLINQ(vm.curWorkChildForm.tableData).where(function (item) {
                        return !item.checked
                    }).ToArray();
                },
                //删除行
                delRow(delRecord) {

                    //不存在在新增中
                    if (JSLINQ(vm.curWorkChildForm.crud.create).where(function (item) {
                        return item.guid == delRecord.guid
                    }).ToArray().length == 0 && JSLINQ(vm.curWorkChildForm.crud.update).where(function (item) {
                        return item.guid == delRecord.guid
                    }).ToArray().length == 0) {
                        vm.curWorkChildForm.crud.delete.push(delRecord);
                    }
                    //存在在更新中
                    else if (JSLINQ(vm.curWorkChildForm.crud.update).where(function (item) {
                        return item.guid == delRecord.guid
                    }).ToArray().length > 0) {
                        vm.curWorkChildForm.crud.update = JSLINQ(vm.curWorkChildForm.crud.update).where(function (item) {
                            return item.guid != delRecord.guid
                        }).ToArray();
                        vm.curWorkChildForm.crud.delete.push(delRecord);
                    } else if (JSLINQ(vm.curWorkChildForm.crud.create).where(function (item) {
                        return item.guid == delRecord.guid
                    }).ToArray().length > 0) {
                        vm.curWorkChildForm.crud.create = JSLINQ(vm.curWorkChildForm.crud.create).where(function (item) {
                            return item.guid != delRecord.guid
                        }).ToArray();
                    }
                },
                //保存事件
                saveRow(callBackEvent) {
                    if (!enabledSubmitBtn) {
                    }
                    else {
                        enabledSubmitBtn = false;
                        //新增操作
                        if (!vm.isUpdate) {
                            //带有Js脚本的，则先执行脚本
                            if (vm.crudList[0].script) {
                                eval(vm.crudList[0].script);
                            }
                            //验证必填项
                            var valitedResult = vm.valitedRequired();
                            if (valitedResult.status == 500) {
                                vm.$toast(valitedResult.msg);
                                enabledSubmitBtn = true;
                                return;
                            } else {
                                var postData = $.extend(vm.formData, {
                                    tableName: vm.physicalTableName,
                                    createWorkSQL: vm.crudList[0].sql
                                });

                                if (APP.getUserInfo()) {
                                    if (!postData.hasOwnProperty("P_UserID")) {
                                        postData.P_UserID = APP.getUserInfo().UserID;
                                        postData.P_UserName = APP.getUserInfo().UserName;
                                        postData.P_UserCode = APP.getUserInfo().UserCode;
                                    }
                                }



                                $.post(APP.serverIP() + "/SQLData/InsertSingleRow", postData, function (data) {
                                    // console.log(JSON.stringify(data));
                                    if (data.status == 500) {
                                        vm.$toast(data.msg);
                                    } else {
                                        vm.isUpdate = true;
                                        //vm.$toast("新增成功");
                                        var keyObj = data.data;
                                        //
                                        api.pageParam.keyName = keyObj.keyName;
                                        api.pageParam.keyValue = keyObj.keyValue;
                                        vm.formData[api.pageParam.keyName] = api.pageParam.keyValue;

                                        //同步外键值
                                        for (var i = 0; i < vm.childFormList.length; i++) {
                                            var connectParams = vm.childFormList[i].connectParams;
                                            for (var j = 0; j < vm.childFormList[i].tableData.length; j++) {
                                                vm.childFormList[i].tableData[j][connectParams] = vm.formData[connectParams];
                                            }
                                            for (var j = 0; j < vm.childFormList[i].crud.create.length; j++) {
                                                vm.childFormList[i].crud.create[j][connectParams] = vm.formData[connectParams];
                                            }
                                            for (var j = 0; j < vm.childFormList[i].crud.update.length; j++) {
                                                vm.childFormList[i].crud.update[j][connectParams] = vm.formData[connectParams];
                                            }
                                            for (var j = 0; j < vm.childFormList[i].crud.delete.length; j++) {
                                                vm.childFormList[i].crud.delete[j][connectParams] = vm.formData[connectParams];
                                            }
                                        }


                                        //子表提交（使用同步提交,数量少的情况下提交）
                                        var isSuccess = true;
                                        for (var i = 0; i < vm.childFormList.length; i++) {
                                            if (vm.childFormList[i].crud.create.length > 0 ||
                                                vm.childFormList[i].crud.update.length > 0 ||
                                                vm.childFormList[i].crud.delete.length > 0) {

                                                //验证必填项
                                                var result = vm.valitedChildForm(vm.childFormList[i], vm.childFormList[i].crud.create, vm.childFormList[i].crud.update);
                                                if (result.valited) {


                                                    $.ajax({
                                                        url: APP.serverIP() + "/FormList/SaveData",
                                                        type: "post",
                                                        dataType: "json",
                                                        async: false,
                                                        data: {
                                                            tableName: vm.childFormList[i].params.physicalTableName,
                                                            create: vm.childFormList[i].crud.create,
                                                            update: vm.childFormList[i].crud.update,
                                                            delete: vm.childFormList[i].crud.delete,
                                                            createWork: vm.childFormList[i].crudList[0].sql,
                                                            updateWork: vm.childFormList[i].crudList[1].sql,
                                                            deleteWork: vm.childFormList[i].crudList[2].sql

                                                        },
                                                        success: function (data) {

                                                            if (data.status == 500) {
                                                                vm.$toast(data.msg);
                                                                isSuccess = false;
                                                            } else {
                                                                vm.childPageInit(vm.childFormList[i]);
                                                                vm.childFormList[i].crud.create = [];
                                                                vm.childFormList[i].crud.update = [];
                                                                vm.childFormList[i].crud.delete = [];
                                                            }
                                                        }
                                                    });
                                                } else {
                                                    vm.$toast(result.valitedColumn + "不能为空!");
                                                    isSuccess = false;
                                                }
                                            }
                                        }
                                        if (isSuccess) {
                                            vm.$toast("保存成功");
                                            //刷新整体表单
                                            tableConfig.initConfig(api.pageParam.moduleName, "");
                                            setTimeout(function () {
                                                enabledSubmitBtn = true;
                                            }, 1000);
                                        }
                                        if (vm.crudList[0].finishSql) {
                                            let formData = $.extend(vm.formData, {
                                                sql: vm.crudList[0].finishSql,
                                                P_UserID: APP.getUserInfo().UserID,
                                                P_UserName: APP.getUserInfo().UserName,
                                                P_UserCode: APP.getUserInfo().UserCode
                                            });
                                            //alert(JSON.stringify(formData));
                                            $.ajax({
                                                url: APP.serverIP() + "/SQLData/QuerySql",
                                                type: "post",
                                                dataType: "json",
                                                async: false,
                                                data: formData,
                                                success: function (data) {
                                                    console.log(JSON.stringify(data))
                                                    //alert(JSON.stringify(data));
                                                    data = data.data;
                                                    if (data.status == 200) {
                                                        if (data.ds.length > 0) {
                                                            vm.$toast(data.ds[0].msg);
                                                        }
                                                    } else {
                                                        vm.$toast(data.msg);

                                                    }
                                                }
                                            });
                                        }
                                        if (typeof (callBackEvent) == 'function') {
                                            callBackEvent();
                                        }
                                    }
                                }, "json");
                            }
                        } else {
                            //带有Js脚本的，则先执行脚本
                            if (vm.crudList[1].script) {
                                eval(vm.crudList[1].script);
                            }
                            //任何保存前先调用主表验证SQL
                            var checkSQL = vm.crudList[1].sql;
                            var isCheck = true;
                            if (checkSQL) {
                                var postData = $.extend(vm.formData, {
                                    tableName: vm.physicalTableName,
                                    keyValue: api.pageParam.keyValue,
                                    updateWorkSQL: checkSQL
                                });
                                $.ajax({
                                    url: APP.serverIP() + "/SQLData/UpdateSingleRowByRollBack",
                                    async: false,
                                    data: postData,
                                    type: "post",
                                    dataType: 'json',
                                    success: function (data) {
                                        if (data.status == 500) {
                                            vm.$toast(data.msg);
                                            isCheck = false;
                                            //vm.isSaveBtnEnabled = true;
                                            return;
                                        }
                                    }
                                });
                            }
                            if (isCheck) {
                                var valitedResult = vm.valitedRequired();
                                if (valitedResult.status == 500) {
                                    vm.$toast(valitedResult.msg);
                                    //vm.isSaveBtnEnabled = true;
                                    enabledSubmitBtn = true;
                                    return;
                                }
                                var postData = $.extend(vm.formData, {
                                    tableName: vm.physicalTableName,
                                    keyValue: api.pageParam.keyValue,
                                    updateWorkSQL: vm.crudList[1].sql
                                });

                                if (APP.getUserInfo()) {
                                    if (!postData.hasOwnProperty("P_UserID")) {
                                        postData.P_UserID = APP.getUserInfo().UserID;
                                        postData.P_UserName = APP.getUserInfo().UserName;
                                        postData.P_UserCode = APP.getUserInfo().UserCode;
                                    }
                                }








                                $.post(APP.serverIP() + "/SQLData/UpdateSingleRow", postData, function (data) {

                                    if (data.status == 500) {
                                        vm.$toast(data.msg);
                                        vm.isSaveBtnEnabled = true;
                                        enabledSubmitBtn = true;
                                    } else {
                                        //子表提交（使用同步提交,数量少的情况下提交）
                                        var isSuccess = true;
                                        for (var i = 0; i < vm.childFormList.length; i++) {
                                            if (vm.childFormList[i].crud.create.length > 0 ||
                                                vm.childFormList[i].crud.update.length > 0 ||
                                                vm.childFormList[i].crud.delete.length > 0) {
                                                //验证必填项
                                                var result = vm.valitedChildForm(vm.childFormList[i], vm.childFormList[i].crud.create, vm.childFormList[i].crud.update);

                                                // console.log(JSON.stringify({
                                                //     tableName: vm.childFormList[i].params.physicalTableName,
                                                //     create: vm.childFormList[i].crud.create,
                                                //     update: vm.childFormList[i].crud.update,
                                                //     delete: vm.childFormList[i].crud.delete,
                                                //     createWork: vm.childFormList[i].crudList[0].sql,
                                                //     updateWork: vm.childFormList[i].crudList[1].sql,
                                                //     deleteWork: vm.childFormList[i].crudList[2].sql

                                                // }));


                                                if (result.valited) {
                                                    $.ajax({
                                                        url: APP.serverIP() + "/FormList/SaveData",
                                                        type: "post",
                                                        dataType: "json",
                                                        async: false,
                                                        data: {
                                                            tableName: vm.childFormList[i].params.physicalTableName,
                                                            create: vm.childFormList[i].crud.create,
                                                            update: vm.childFormList[i].crud.update,
                                                            delete: vm.childFormList[i].crud.delete,
                                                            createWork: vm.childFormList[i].crudList[0].sql,
                                                            updateWork: vm.childFormList[i].crudList[1].sql,
                                                            deleteWork: vm.childFormList[i].crudList[2].sql

                                                        },
                                                        success: function (data) {
                                                            //console.log(JSON.stringify(data))
                                                            enabledSubmitBtn = true;
                                                            if (data.status == 500) {
                                                                vm.$toast(data.msg);
                                                                isSuccess = false;
                                                            } else {
                                                                vm.childPageInit(vm.childFormList[i]);
                                                                vm.childFormList[i].crud.create = [];
                                                                vm.childFormList[i].crud.update = [];
                                                                vm.childFormList[i].crud.delete = [];
                                                            }
                                                        }
                                                    });
                                                } else {
                                                    vm.$toast(result.valitedColumn + "不能为空!");
                                                    isSuccess = false;
                                                }
                                            }
                                        }
                                        if (isSuccess) {
                                            vm.$toast("保存成功");
                                            tableConfig.initConfig(api.pageParam.moduleName, "");
                                        }



                                        if (vm.crudList[0].finishSql) {
                                            let formData = $.extend(vm.formData, {
                                                sql: vm.crudList[0].finishSql
                                            });
                                            $.ajax({
                                                url: APP.serverIP() + "/SQLData/QuerySql",
                                                type: "post",
                                                dataType: "json",
                                                async: false,
                                                data: formData,
                                                success: function (data) {
                                                    if (data.status == 200) {
                                                        if (data.ds.length > 0) {
                                                            vm.$toast(data.ds[0].msg);
                                                        }
                                                    } else {
                                                        vm.$toast(data.msg);
                                                    }
                                                }
                                            });
                                        }

                                        if (typeof (callBackEvent) == 'function') {
                                            callBackEvent();
                                        }

                                    }
                                    //vm.resetPage();
                                    //vm.refreshPage(false);
                                    //}
                                    enabledSubmitBtn = true;
                                }, "json");
                            }
                        }
                    }


                },
                //计算合计数据
                calSummaryData(childForm) {

                },
                //获取列下拉数据源对象
                queryColumnObj(rowDataSource, colName, condition, objValue) {
                    var currentCol = [];
                    for (var i = 0; i < vm.formDesign.length; i++) {
                        for (var j = 0; j < vm.formDesign[i].controls.length; j++) {
                            if (vm.formDesign[i].controls[j].baseProperty["controlName"] == colName) {
                                currentCol.push(vm.formDesign[i].controls[j]);
                            }
                        }
                    }
                    var returnArray = [];
                    if (currentCol.length > 0) {
                        currentCol = currentCol[0];
                        try {
                            returnArray = eval("JSLINQ(currentCol.controlProperty.select.sqlDataSource).where(function (item) { return item." + condition + "; }).ToArray()");
                        } catch (e) {
                            returnArray = [];
                        }
                    }
                    var returnValue = "";
                    if (returnArray.length > 0) {
                        returnValue = returnArray[0][objValue];
                    }
                    return returnValue;
                },
                onClickLeft: function () {
                    // api.setScreenOrientation({
                    //     orientation: 'portrait_up'
                    // })
                    api.sendEvent({
                        name: 'refresh'
                    });
                    api.closeWin();
                }
            }
        })

        //启动部分
        var tableConfig = {
            //设置配置
            set: function (options, isRefreshChildWindow) {
                if (options.childFormList == null) {
                    options.childFormList = [];
                }
                if (vm.childFormList.length == 0) {
                    vm.childFormList = options.childFormList;
                }
                vm.scanConfig = options.scanConfig;
                vm.printConfig = options.printConfig;

                for (let i = 0; i < vm.childFormList.length; i++) {

                    if (vm.childFormList[i].defaultParams || vm.childFormList[i].transChildParams) {
                        vm.isWatch = true;
                    }
                    let curFormList = vm.childFormList[i];
                    //绑定双击事件
                    vm.childFormList[i].dblClick = function (row) {
                        vm.editChildRow(curFormList, row);
                    }
                    //vm.childFormList[i].showType = 'table';
                    //item类型下的变量数据
                    vm.childFormList[i].showListLoading = false;
                    vm.childFormList[i].finished = false;
                    vm.childFormList[i].pageIndex = 1;
                    vm.childFormList[i].pageSize = 30;
                    vm.childFormList[i].isLoading = false;
                    vm.childFormList[i].crud = {
                        create: [],
                        update: [],
                        delete: []
                    };


                    vm.childFormList[i].handleSizeChange = function () {
                        var curChildObj = curFormList;//vm.childFormList[i];
                        if (curChildObj.isLoading) {
                            return;
                        } else {
                            curChildObj.isLoading = true;
                        }
                        var filterCondition = '1=1';
                        if (curChildObj.params.filterCondition) {
                            filterCondition += ' and ' + curChildObj.params.filterCondition;
                        }
                        let connectParams = vm.formData[curChildObj['connectParams']];
                        if (!connectParams) {
                            filterCondition += " and 1=0 ";
                        } else {
                            filterCondition += " and " + curChildObj['connectParams'] + "='" + vm.formData[curChildObj['connectParams']] + "'";
                        }


                        APP.ajax2('/SQLData/GetDataByPhysicalTableNameByQueryPaging', {
                            tableName: curChildObj.params.physicalTableName,
                            columns: [],
                            currentCol: '',
                            pageIndex: curChildObj.pageIndex,
                            pageSize: curChildObj.pageSize,
                            isForm: curChildObj.params.isFormList || true,
                            filterCondition: filterCondition,
                            defaultOrder: curChildObj.params.defaultOrder || ''
                        }, function (data) {
                            var tableData = data.ds;
                            curChildObj.isLoading = false;
                            //console.log(curChildObj.pageIndex)
                            // console.log(JSON.stringify(data.ds))

                            curChildObj.showListLoading = false;
                            if (curChildObj.pageIndex == 1) {
                                //.log(JSON.stringify(data.ds))
                                vm.$set(curChildObj, "tableData", data.ds);
                            } else {
                                curChildObj.tableData = curChildObj.tableData.concat(data.ds);
                            }
                            for (var i = 0; i < curChildObj.tableData.length; i++) {
                                curChildObj.tableData[i].objNo = (i + 1).toString();
                                if (!curChildObj.tableData[i].guid) {
                                    curChildObj.tableData[i].guid = vm.guid();
                                }
                            }
                            if (data.ds1.length > 0) {
                                //绑定总长度
                                if (curChildObj.tableData.length >= parseInt(data.ds1[0]["@TotalCount"])) {
                                    curChildObj.finished = true;
                                }
                            }
                            curChildObj.pageIndex = curChildObj.pageIndex + 1;

                            // for(var i=0;i<tableData.length;i++){
                            //   tableData[i].objNo = (i+1).toString();
                            // }
                            //
                            // vm.$set(curChildObj, "tableData",tableData );
                            vm.refreshChildCol(curChildObj);


                        }, function () {
                            vm.tableData = [];
                        });


                    }

                }

                //var rowDesignFormData = [];
                if (!options.formDesign) {
                    options.formDesign = [];
                }
                vm.reportUrl = options.reportUrl;

                for (var i = 0; i < options.formDesign.length; i++) {
                    if (options.formDesign[i].baseProperty.controlType == "select") {
                        //下拉框数据加载
                        if (options.formDesign[i].controlProperty.select.type < 3) {

                            var sql = options.formDesign[i].controlProperty.select.dataSource;
                            $.ajax({
                                url: APP.serverIP() + "/SQLData/GetDataBySql",
                                async: false,
                                data: {
                                    sql: sql
                                },
                                type: "post",
                                dataType: 'json',
                                success: function (data) {
                                    if (data.status == 200) {
                                        vm.$set(options.formDesign[i].controlProperty.select, "sqlDataSource", data.data.ds);
                                        vm.$set(options.formDesign[i].controlProperty.select, "originDataSource", data.data.ds);

                                        //判断隐藏值类型和当前赋值类型是否一致
                                        if (data.data.ds.length > 0 && vm.formData[options.formDesign[i].baseProperty.controlName] != undefined && vm.formData[options.formDesign[i].baseProperty.controlName] != null) {
                                            var dataType = typeof (data.data.ds[0][options.formDesign[i].controlProperty.select.hiddenValue]);

                                            //alert(options.formDesign[i].baseProperty.controlName+','+typeof (vm.formData[options.formDesign[i].baseProperty.controlName]));

                                            if (dataType != typeof (vm.formData[options.formDesign[i].baseProperty.controlName])) {
                                                if (dataType == "int" || dataType == "number") {


                                                    vm.formData[options.formDesign[i].baseProperty.controlName] = parseInt(vm.formData[options.formDesign[i].baseProperty.controlName]);
                                                } else if (dataType == "boolean") {
                                                    vm.formData[options.formDesign[i].baseProperty.controlName] = Boolean(parseInt(vm.formData[options.formDesign[i].baseProperty.controlName]));
                                                }
                                            } else {
                                                vm.formData[options.formDesign[i].baseProperty.controlName] = vm.formData[options.formDesign[i].baseProperty.controlName];
                                            }
                                            vm.formData[options.formDesign[i].baseProperty.controlName + '_show'] = ''

                                            var curDs = JSLINQ(data.data.ds).where(function (item) {
                                                return item[options.formDesign[i].controlProperty.select.hiddenValue] == vm.formData[options.formDesign[i].baseProperty.controlName]
                                            }).ToArray();
                                            if (curDs.length > 0) {
                                                vm.formData[options.formDesign[i].baseProperty.controlName + '_show'] = curDs[0][options.formDesign[i].controlProperty.select.displayValue]
                                            }
                                        }
                                    }
                                }
                            });
                        } else if (options.formDesign[i].controlProperty.select.type == 3) {
                            if (options.formDesign[i].controlProperty.select.chooseType == 1) {
                                var valueList = [];
                                if (vm.formData[options.formDesign[i].baseProperty.controlName] != undefined && vm.formData[options.formDesign[i].baseProperty.controlName] !== "") {
                                    valueList.push("'" + vm.formData[options.formDesign[i].baseProperty.controlName] + "'");
                                }
                                var sql = "select * from (" + options.formDesign[i].controlProperty.select.dataSource + ")t";
                                //带有@@父节点标识的字段
                                if (sql.indexOf('@@') >= 0) {
                                    for (var name in vm.formData) {
                                        var repalceValue = "'" + vm.formData[name] + "'";
                                        eval("sql = sql.replace(/@@" + name + "/g, repalceValue)");
                                    }
                                    //console.log(sql);
                                }




                                if (valueList.length > 0) {
                                    sql += " where " + options.formDesign[i].controlProperty.select.hiddenValue + " in (" + valueList.join(',') + ") ";

                                    $.ajax({
                                        url: APP.serverIP() + "/SQLData/GetDataBySql",
                                        async: false,
                                        data: {
                                            sql: sql,
                                            sqlParam: vm.formData
                                        },
                                        type: "post",
                                        dataType: 'json',
                                        success: function (data) {
                                            console.log(sql);
                                            console.log(options.formDesign[i].baseProperty.controlName + ',' + JSON.stringify(data));
                                            if (data.status == 200) {
                                                //options.formDesign[i].controlProperty.select["sqlDataSource"] = data.data.ds;
                                                //options.formDesign[i].controlProperty.select["originDataSource"] = data.data.ds;
                                                vm.$set(options.formDesign[i].controlProperty.select, "sqlDataSource", data.data.ds);
                                                vm.$set(options.formDesign[i].controlProperty.select, "originDataSource", data.data.ds);
                                                //绑定固定值
                                                vm.$set(options.formDesign[i].controlProperty.select, "actualName", "");
                                                //options.formDesign[i].controlProperty.select["actualName"] = "";
                                                var actualList = JSLINQ(data.data.ds).where(function (item) {
                                                    return item[options.formDesign[i].controlProperty.select.hiddenValue] == vm.formData[options.formDesign[i].baseProperty.controlName]
                                                }).ToArray();
                                                vm.formData[options.formDesign[i].baseProperty.controlName + '_show'] = ''
                                                if (actualList.length > 0) {
                                                    vm.$set(options.formDesign[i].controlProperty.select, "actualName", actualList[0][options.formDesign[i].controlProperty.select.displayValue]);
                                                    //options.formDesign[i].controlProperty.select["actualName"] = actualList[0][options.formDesign[i].controlProperty.select.displayValue];
                                                    vm.formData[options.formDesign[i].baseProperty.controlName + '_show'] = actualList[0][options.formDesign[i].controlProperty.select.displayValue];
                                                }
                                            } else {
                                                vm.formData[options.formDesign[i].baseProperty.controlName + '_show'] = '';
                                            }
                                        }
                                    });
                                } else {
                                    vm.$set(options.formDesign[i].controlProperty.select, "sqlDataSource", []);
                                    //options.formDesign[i].controlProperty.select["sqlDataSource"] = [];
                                    vm.$set(options.formDesign[i].controlProperty.select, "originDataSource", []);
                                    //options.formDesign[i].controlProperty.select["originDataSource"] = [];
                                    vm.$set(options.formDesign[i].controlProperty.select, "actualName", "");

                                    vm.formData[options.formDesign[i].baseProperty.controlName + '_show'] = '';
                                    //options.formDesign[i].controlProperty.select["actualName"] = [];

                                }
                            } else {
                                var valueList = "";
                                if (vm.formData[options.formDesign[i].baseProperty.controlName] != undefined && vm.formData[options.formDesign[i].baseProperty.controlName] != "") {
                                    let valueArray = [];
                                    valueArray = vm.formData[options.formDesign[i].baseProperty.controlName].toString().split(',');
                                    for (var q = 0; q < valueArray.length; q++) {
                                        valueArray[q] = "'" + valueArray[q] + "'";
                                    }
                                    valueList = valueArray.join(',');
                                }
                                var sql = "select * from (" + options.formDesign[i].controlProperty.select.dataSource + ")t";
                                if (valueList) {
                                    sql += " where " + options.formDesign[i].controlProperty.select.hiddenValue + " in (" + valueList + ") ";
                                    $.ajax({
                                        url: APP.serverIP() + "/SQLData/GetDataBySql",
                                        async: false,
                                        data: {
                                            sql: sql,
                                            sqlParam: vm.formData
                                        },
                                        type: "post",
                                        dataType: 'json',
                                        success: function (data) {
                                            if (data.status == 200) {
                                                vm.$set(options.formDesign[i].controlProperty.select, "sqlDataSource", data.data.ds);
                                                vm.$set(options.formDesign[i].controlProperty.select, "originDataSource", data.data.ds);
                                                //绑定固定值
                                                vm.$set(options.formDesign[i].controlProperty.select, "actualName", "");
                                                var displayValue = JSLINQ(data.data.ds).select(function (item) {
                                                    return item[options.formDesign[i].controlProperty.select.displayValue]
                                                }).ToArray().join(',');
                                                vm.$set(options.formDesign[i].controlProperty.select, "actualName", displayValue);
                                                vm.formData[options.formDesign[i].baseProperty.controlName + '_show'] = displayValue;
                                            }
                                        }
                                    });
                                } else {
                                    vm.$set(options.formDesign[i].controlProperty.select, "actualName", "");
                                    vm.$set(options.formDesign[i].controlProperty.select, "sqlDataSource", []);
                                    //vm.formDesign[i].controls[j].controlProperty.select["sqlDataSource"] = [];
                                    vm.$set(options.formDesign[i].controlProperty.select, "originDataSource", []);
                                    vm.formData[options.formDesign[i].baseProperty.controlName + '_show'] = ''
                                }
                            }
                        }
                    }
                    if (options.formDesign[i].baseProperty.controlType == "fileUpload") {
                        //console.log(vm.formData[options.formDesign[i].baseProperty.controlName]);
                        vm.formData[options.formDesign[i].baseProperty.controlName + '_files'] = vm.uploaderImg(vm.formData[options.formDesign[i].baseProperty.controlName]);
                        //console.log(JSON.stringify(vm.formData))
                    }
                    if (options.formDesign[i].baseProperty.controlType == "textbox" || options.formDesign[i].baseProperty.controlType == "datepicker") {
                        vm.dataChange(options.formDesign[i]);
                    }



                }


                vm.formDesign = options.formDesign;
                for (var i = 0; i < vm.formDesign.length; i++) {
                    if (vm.formDesign[i].baseProperty.controlType == "textbox" || vm.formDesign[i].baseProperty.controlType == "datepicker") {
                        vm.dataChange(vm.formDesign[i]);
                    }
                }


                vm.physicalTableName = options.physicalTableName;
                vm.workList = options.workList;
                for (var i = 0; i < vm.workList.length; i++) {
                    vm.workList[i].disabled = false;
                }

                vm.crudList = options.crudList;
                setTimeout(function () {
                    vm.controlInit();
                }, 200);
                vm.pageInit(isRefreshChildWindow);
            },
            //初始化配置
            initConfig: function (objName, isRefreshChildWindow) {
                APP.ajax2('/AppFormDetail/GetDataByName', {
                    objName: objName
                }, function (data) {
                    console.log('data', JSON.stringify(data))
                    $.globalData = data;
                    //判断主键字段是否存在
                    vm.physicalTableName = data.ds[0].physicalTableName;
                    console.log(data.ds[0].physicalTableName)
                    // console.log(api.pageParam.keyValue)
                    if (api.pageParam.keyName && api.pageParam.keyValue) {
                        vm.isUpdate = true;

                        APP.ajax2("/SQLData/GetTableByKeyId", {
                            physicalTableName: data.ds[0].physicalTableName,
                            keyName: api.pageParam.keyName,
                            keyValue: api.pageParam.keyValue
                        }, function (data) {
                            // console.log(JSON.stringify(data));
                            if (data.ds.length > 0) {
                                var result = data.ds[0];
                                vm.formData = result;
                                tableConfig.set({
                                    childFormList: JSON.parse($.globalData.ds[0].childFormsConfig),
                                    formDesign: JSON.parse($.globalData.ds[0].formDesignConfig),
                                    physicalTableName: $.globalData.ds[0].physicalTableName,
                                    workList: JSON.parse($.globalData.ds[0].worksConfig),
                                    crudList: JSON.parse($.globalData.ds[0].crudConfig),
                                    importConfig: JSON.parse($.globalData.ds[0].importConfig),
                                    reportUrl: JSON.parse($.globalData.ds[0].reportUrl),
                                    scanConfig: $.globalData.ds[0].scanConfig,
                                    printConfig: $.globalData.ds[0].printConfig
                                }, isRefreshChildWindow);
                            }
                            //vm.pageInit(isRefreshChildWindow);
                        });
                    } else {
                        vm.isUpdate = false;
                        //设置默认值
                        if (data.ds[0].formDesignConfig) {
                            var newFormData = {};
                            var designControls = JSON.parse(data.ds[0].formDesignConfig);
                            for (var i = 0; i < designControls.length; i++) {
                                if (designControls[i].baseProperty.defaultValue && designControls[i].baseProperty.defaultValue.indexOf('@') < 0) {
                                    newFormData[designControls[i].baseProperty.controlName] = vm.getSYDefaultValue(designControls[i].baseProperty.defaultValue);
                                }
                                else if (designControls[i].baseProperty.defaultValue && designControls[i].baseProperty.defaultValue.indexOf('@') >= 0) {
                                    var userInfo = vm.getSYDefaultValue(designControls[i].baseProperty.defaultValue);
                                    if (designControls[i].baseProperty.defaultValue && designControls[i].baseProperty.defaultValue.indexOf('Code') >= 0) {
                                        newFormData[designControls[i].baseProperty.controlName] = userInfo.P_UserCode;
                                    }
                                    else {
                                        newFormData[designControls[i].baseProperty.controlName] = userInfo.P_UserID;
                                    }
                                    newFormData[designControls[i].baseProperty.controlName + '_show'] = userInfo.P_UserName;
                                }
                                else {
                                    newFormData[designControls[i].baseProperty.controlName] = "";
                                }
                            }
                            vm.formData = newFormData;
                        }
                        tableConfig.set({
                            childFormList: JSON.parse(data.ds[0].childFormsConfig),
                            formDesign: JSON.parse(data.ds[0].formDesignConfig),
                            physicalTableName: data.ds[0].physicalTableName,
                            workList: JSON.parse(data.ds[0].worksConfig),
                            crudList: JSON.parse(data.ds[0].crudConfig),
                            importConfig: JSON.parse(data.ds[0].importConfig),
                            reportUrl: JSON.parse($.globalData.ds[0].reportUrl),
                            scanConfig: data.ds[0].scanConfig,
                            printConfig: data.ds[0].printConfig
                        }, isRefreshChildWindow);
                    }
                });
            }
        }

        $(function () {
            var moduleName = api.pageParam.moduleName;
            tableConfig.initConfig(moduleName, "");
        });
    }
</script>